Commit 7bb97fa2 authored by Laurent Montel's avatar Laurent Montel 😁

Move here

parent 3bbae100
......@@ -3,4 +3,4 @@ add_subdirectory(autotests)
add_subdirectory(ms-tnef)
add_subdirectory(vcard)
add_subdirectory(xdiff)
add_subdirectory(calendar)
add_definitions(-DTRANSLATION_DOMAIN=\"messageviewer_text_calendar_plugin\")
set(messageviewer_bodypartformatter_text_calendar_PART_SRCS text_calendar.cpp delegateselector.cpp attendeeselector.cpp memorycalendarmemento.cpp syncitiphandler.cpp)
ecm_qt_declare_logging_category(messageviewer_bodypartformatter_text_calendar_PART_SRCS HEADER text_calendar_debug.h IDENTIFIER TEXT_CALENDAR_LOG CATEGORY_NAME log_text_calendar)
qt5_add_dbus_interfaces(messageviewer_bodypartformatter_text_calendar_PART_SRCS
korganizer/org.kde.Korganizer.Calendar.xml
)
ki18n_wrap_ui(messageviewer_bodypartformatter_text_calendar_PART_SRCS attendeeselector.ui)
add_library(messageviewer_bodypartformatter_text_calendar MODULE ${messageviewer_bodypartformatter_text_calendar_PART_SRCS})
target_link_libraries(messageviewer_bodypartformatter_text_calendar
KF5::Codecs
Qt5::Core
KF5::CalendarCore
KF5::CalendarUtils
KF5::Mime
KF5::IdentityManagement
KF5::MailTransport
KF5::AkonadiMime
KF5::CalendarSupport
KF5::Libkdepim
KF5::MessageViewer
KF5::IncidenceEditor
)
install(TARGETS messageviewer_bodypartformatter_text_calendar DESTINATION ${KDE_INSTALL_PLUGINDIR})
install(FILES text_calendar.desktop DESTINATION ${KDE_INSTALL_DATADIR}/messageviewer/plugins/bodypartformatter)
#! /bin/sh
$EXTRACTRC *.ui >> rc.cpp
$XGETTEXT *.cpp -o $podir/messageviewer_text_calendar_plugin.pot
/*
Copyright (c) 2007 Volker Krause <vkrause@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library 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 Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#include "attendeeselector.h"
#include <Libkdepim/AddresseeLineEdit>
#include <KEmailAddress>
#include <KLocalizedString>
#include <QPushButton>
#include <KGuiItem>
#include <KStandardGuiItem>
#include <KConfigGroup>
#include <QDialogButtonBox>
#include <QVBoxLayout>
AttendeeSelector::AttendeeSelector(QWidget *parent)
: QDialog(parent)
{
setWindowTitle(i18n("Select Attendees"));
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
QWidget *mainWidget = new QWidget(this);
QVBoxLayout *mainLayout = new QVBoxLayout;
setLayout(mainLayout);
mainLayout->addWidget(mainWidget);
mOkButton = buttonBox->button(QDialogButtonBox::Ok);
mOkButton->setDefault(true);
mOkButton->setShortcut(Qt::CTRL | Qt::Key_Return);
connect(buttonBox, &QDialogButtonBox::accepted, this, &AttendeeSelector::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &AttendeeSelector::reject);
mainLayout->addWidget(buttonBox);
ui.setupUi(mainWidget);
KGuiItem::assign(ui.addButton, KStandardGuiItem::add());
connect(ui.addButton, &QPushButton::clicked, this, &AttendeeSelector::addClicked);
KGuiItem::assign(ui.removeButton, KStandardGuiItem::remove());
connect(ui.removeButton, &QPushButton::clicked, this, &AttendeeSelector::removeClicked);
ui.attendeeEdit->setPlaceholderText(i18n("Click to add a new attendee"));
connect(ui.attendeeEdit, &KPIM::AddresseeLineEdit::textChanged, this, &AttendeeSelector::textChanged);
connect(ui.attendeeEdit, &KPIM::AddresseeLineEdit::returnPressed, this, &AttendeeSelector::addClicked);
connect(ui.attendeeList, &QListWidget::itemSelectionChanged, this, &AttendeeSelector::selectionChanged);
mOkButton->setEnabled(false);
}
QStringList AttendeeSelector::attendees() const
{
QStringList rv;
const int numberOfAttendee(ui.attendeeList->count());
for (int i = 0; i < numberOfAttendee; ++i) {
const QString addr = ui.attendeeList->item(i)->text();
// Build a nice address for this attendee including the CN.
QString tname, temail;
KEmailAddress::extractEmailAddressAndName(addr, temail, tname); // ignore return value
// which is always false
rv << temail;
}
return rv;
}
void AttendeeSelector::addClicked()
{
if (!ui.attendeeEdit->text().isEmpty()) {
ui.attendeeList->addItem(ui.attendeeEdit->text());
}
ui.attendeeEdit->clear();
mOkButton->setEnabled(true);
}
void AttendeeSelector::removeClicked()
{
delete ui.attendeeList->takeItem(ui.attendeeList->currentRow());
mOkButton->setEnabled((ui.attendeeList->count() > 0));
}
void AttendeeSelector::textChanged(const QString &text)
{
ui.addButton->setEnabled(!text.isEmpty());
}
void AttendeeSelector::selectionChanged()
{
ui.removeButton->setEnabled(ui.attendeeList->currentItem());
}
/*
Copyright (c) 2007 Volker Krause <vkrause@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library 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 Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef ATTENDEESELECTOR_H_H
#define ATTENDEESELECTOR_H_H
#include <QDialog>
#include <QPushButton>
#include "ui_attendeeselector.h"
/**
Dialog to select a set off attendees.
*/
class AttendeeSelector : public QDialog
{
Q_OBJECT
public:
explicit AttendeeSelector(QWidget *parent = Q_NULLPTR);
QStringList attendees() const;
private Q_SLOTS:
void addClicked();
void removeClicked();
void textChanged(const QString &text);
void selectionChanged();
private:
Ui::AttendeeSelectorWidget ui;
QPushButton *mOkButton;
};
#endif
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<author>Volker Krause &lt;vkrause@kde.org&gt;</author>
<class>AttendeeSelectorWidget</class>
<widget class="QWidget" name="AttendeeSelectorWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>354</width>
<height>238</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="KPIM::AddresseeLineEdit" name="attendeeEdit"/>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="addButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item row="1" column="0" rowspan="2">
<widget class="QListWidget" name="attendeeList"/>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="removeButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item row="2" column="1">
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>140</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KPIM::AddresseeLineEdit</class>
<extends>KLineEdit</extends>
<header>Libkdepim/AddresseeLineEdit</header>
</customwidget>
<customwidget>
<class>KLineEdit</class>
<extends>QLineEdit</extends>
<header>klineedit.h</header>
</customwidget>
</customwidgets>
<includes>
<include location="local">Libkdepim/AddresseeLineEdit</include>
</includes>
<resources/>
<connections/>
</ui>
/*
Copyright (c) 2007 Volker Krause <vkrause@kde.org>
Copyright (c) 2012 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library 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 Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#include "delegateselector.h"
#include <Libkdepim/AddresseeLineEdit>
#include <QHBoxLayout>
#include <KLocalizedString>
#include <qcheckbox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <KConfigGroup>
#include <QDialogButtonBox>
#include <QPushButton>
#include <QVBoxLayout>
DelegateSelector::DelegateSelector(QWidget *parent)
: QDialog(parent)
{
setWindowTitle(i18n("Select delegate"));
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
QVBoxLayout *mainLayout = new QVBoxLayout;
setLayout(mainLayout);
mOkButton = buttonBox->button(QDialogButtonBox::Ok);
mOkButton->setDefault(true);
mOkButton->setShortcut(Qt::CTRL | Qt::Key_Return);
connect(buttonBox, &QDialogButtonBox::accepted, this, &DelegateSelector::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &DelegateSelector::reject);
mOkButton->setDefault(true);
QWidget *delegateBox = new QWidget(this);
QHBoxLayout *delegateBoxHBoxLayout = new QHBoxLayout(delegateBox);
delegateBoxHBoxLayout->setMargin(0);
new QLabel(i18n("Delegate:"), delegateBox);
mDelegate = new KPIM::AddresseeLineEdit(delegateBox);
connect(mDelegate, &KPIM::AddresseeLineEdit::textChanged, this, &DelegateSelector::slotTextChanged);
mRsvp = new QCheckBox(i18n("Keep me informed about status changes of this incidence."), this);
mRsvp->setChecked(true);
mainLayout->addWidget(delegateBox);
mainLayout->addWidget(mRsvp);
mainLayout->addWidget(buttonBox);
mOkButton->setEnabled(false);
}
void DelegateSelector::slotTextChanged(const QString &text)
{
mOkButton->setEnabled(!text.isEmpty());
}
QString DelegateSelector::delegate() const
{
return mDelegate->text();
}
bool DelegateSelector::rsvp() const
{
return mRsvp->isChecked();
}
/*
Copyright (c) 2007 Volker Krause <vkrause@kde.org>
Copyright (C) 2012-2016 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library 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 Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef DELEGATESELECTOR_H
#define DELEGATESELECTOR_H
#include <QDialog>
class QPushButton;
namespace KPIM
{
class AddresseeLineEdit;
}
class QCheckBox;
/**
Selection dialog for a delegate.
*/
class DelegateSelector : public QDialog
{
Q_OBJECT
public:
explicit DelegateSelector(QWidget *parent = Q_NULLPTR);
QString delegate() const;
bool rsvp() const;
public Q_SLOTS:
void slotTextChanged(const QString &text);
private:
KPIM::AddresseeLineEdit *mDelegate;
QCheckBox *mRsvp;
QPushButton *mOkButton;
};
#endif
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.kde.Korganizer.Calendar">
<method name="showJournalView"/>
<method name="showTodoView"/>
<method name="showEventView"/>
<method name="goDate">
<arg name="date" type="(iii)" direction="in"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QDate"/>
</method>
<method name="goDate">
<arg name="date" type="s" direction="in"/>
</method>
<method name="showDate">
<arg name="date" type="(iii)" direction="in"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QDate"/>
</method>
<method name="openEventEditor">
<arg name="text" type="s" direction="in"/>
</method>
<method name="openEventEditor">
<arg name="summary" type="s" direction="in"/>
<arg name="description" type="s" direction="in"/>
<arg name="attachments" type="as" direction="in"/>
</method>
<method name="openEventEditor">
<arg name="summary" type="s" direction="in"/>
<arg name="description" type="s" direction="in"/>
<arg name="uri" type="s" direction="in"/>
<arg name="file" type="s" direction="in"/>
<arg name="attendees" type="as" direction="in"/>
<arg name="attachmentMimetype" type="s" direction="in"/>
</method>
<method name="openEventEditor">
<arg name="summary" type="s" direction="in"/>
<arg name="description" type="s" direction="in"/>
<arg name="attachments" type="as" direction="in"/>
<arg name="attendees" type="as" direction="in"/>
</method>
<method name="openEventEditor">
<arg name="summary" type="s" direction="in"/>
<arg name="description" type="s" direction="in"/>
<arg name="attachmentUris" type="as" direction="in"/>
<arg name="attendees" type="as" direction="in"/>
<arg name="attachmentMimetypes" type="as" direction="in"/>
<arg name="attachmentIsInline" type="b" direction="in"/>
</method>
<method name="openTodoEditor">
<arg name="text" type="s" direction="in"/>
</method>
<method name="openTodoEditor">
<arg name="summary" type="s" direction="in"/>
<arg name="description" type="s" direction="in"/>
<arg name="attachments" type="as" direction="in"/>
</method>
<method name="openTodoEditor">
<arg name="summary" type="s" direction="in"/>
<arg name="description" type="s" direction="in"/>
<arg name="attachments" type="as" direction="in"/>
<arg name="attendees" type="as" direction="in"/>
</method>
<method name="openTodoEditor">
<arg name="summary" type="s" direction="in"/>
<arg name="description" type="s" direction="in"/>
<arg name="uri" type="s" direction="in"/>
<arg name="file" type="s" direction="in"/>
<arg name="attendees" type="as" direction="in"/>
<arg name="attachmentMimetype" type="s" direction="in"/>
</method>
<method name="openTodoEditor">
<arg name="summary" type="s" direction="in"/>
<arg name="description" type="s" direction="in"/>
<arg name="attachmentUris" type="as" direction="in"/>
<arg name="attendees" type="as" direction="in"/>
<arg name="attachmentMimetypes" type="as" direction="in"/>
<arg name="attachmentIsInline" type="b" direction="in"/>
</method>
<method name="openJournalEditor">
<arg name="date" type="(iii)" direction="in"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QDate"/>
</method>
<method name="openJournalEditor">
<arg name="text" type="s" direction="in"/>
<arg name="date" type="(iii)" direction="in"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="QDate"/>
</method>
<method name="openJournalEditor">
<arg name="text" type="s" direction="in"/>
</method>
</interface>
</node>
/* Copyright (C) 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.net>
Author: Sérgio Martins <sergio.martins@kdab.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License or (at your option) version 3 or any later version
accepted by the membership of KDE e.V. (or its successor approved
by the membership of KDE e.V.), which shall act as a proxy
defined in Section 14 of version 3 of the license.
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, see <http://www.gnu.org/licenses/>.
*/
#include "memorycalendarmemento.h"
#include <CalendarSupport/CalendarSingleton>
#include <Akonadi/Calendar/FetchJobCalendar>
#include <Akonadi/Calendar/ETMCalendar>
#include "text_calendar_debug.h"
using namespace MessageViewer;
using namespace Akonadi;
MemoryCalendarMemento::MemoryCalendarMemento()
: QObject(0), mFinished(false)
{
Akonadi::ETMCalendar::Ptr etmCalendar = CalendarSupport::calendarSingleton(/*createIfNull=*/false);
if (etmCalendar && etmCalendar->isLoaded()) {
// Good, either korganizer or kontact summary view are already running, so reuse ETM to save memory
mCalendar = etmCalendar;
QMetaObject::invokeMethod(this, "finalize", Qt::QueuedConnection);
} else {
FetchJobCalendar::Ptr calendar = FetchJobCalendar::Ptr(new FetchJobCalendar(this));
mCalendar = calendar;
connect(calendar.data(), &FetchJobCalendar::loadFinished,
this, &MemoryCalendarMemento::slotCalendarLoaded);
}
}
void MemoryCalendarMemento::slotCalendarLoaded(bool success, const QString &errorMessage)
{
qCDebug(TEXT_CALENDAR_LOG);
if (!success) {
qCWarning(TEXT_CALENDAR_LOG) << "Unable to fetch incidences:" << errorMessage;
}
finalize();
}
void MemoryCalendarMemento::finalize()
{
mFinished = true;
Q_EMIT update(MimeTreeParser::Delayed);
}
bool MemoryCalendarMemento::finished() const
{
return mFinished;
}
KCalCore::MemoryCalendar::Ptr MemoryCalendarMemento::calendar() const
{
Q_ASSERT(mFinished);
return mCalendar;
}
void MemoryCalendarMemento::detach()
{