26 #include "kmailinterface.h"
29 #include <KABC/VCardDrag>
30 #include <KCalCore/MemoryCalendar>
31 #include <KCalCore/FileStorage>
32 #include <KCalUtils/ICalDrag>
33 #include <KCalUtils/VCalDrag>
35 #include <KontactInterface/Core>
38 #include <KActionCollection>
42 #include <KStandardDirs>
43 #include <KTemporaryFile>
47 using namespace KCalUtils;
48 using namespace KCalCore;
53 : KontactInterface::Plugin( core, core, "kmail2" ), m_instance( 0 )
55 setComponentData( KontactPluginFactory::componentData() );
58 new KAction( KIcon( QLatin1String(
"mail-message-new") ),
59 i18nc(
"@action:inmenu",
"New Message..." ),
this );
60 actionCollection()->addAction( QLatin1String(
"new_mail"), action );
61 action->setShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_M ) );
63 i18nc(
"@info:status",
"Create a new mail message" ) );
65 i18nc(
"@info:whatsthis",
66 "You will be presented with a dialog where you can create "
67 "and send a new email message." ) );
68 connect( action, SIGNAL(triggered(
bool)), SLOT(slotNewMail()) );
69 insertNewAction( action );
72 new KAction( KIcon( QLatin1String(
"view-refresh") ),
73 i18nc(
"@action:inmenu",
"Sync Mail" ),
this );
74 syncAction->setHelpText(
75 i18nc(
"@info:status",
"Synchronize groupware mail" ) );
76 syncAction->setWhatsThis(
77 i18nc(
"@info:whatsthis",
78 "Choose this option to synchronize your groupware email." ) );
79 connect( syncAction, SIGNAL(triggered(
bool)), SLOT(slotSyncFolders()) );
80 actionCollection()->addAction( QLatin1String(
"sync_mail"), syncAction );
81 insertSyncAction( syncAction );
83 mUniqueAppWatcher =
new KontactInterface::UniqueAppWatcher(
84 new KontactInterface::UniqueAppHandlerFactory<KMailUniqueAppHandler>(),
this );
97 MemoryCalendar::Ptr cal(
new MemoryCalendar( QString::fromLatin1(
"UTC" ) ) );
98 KABC::Addressee::List list;
103 tmp.setPrefix( QLatin1String(
"incidences-") );
104 tmp.setSuffix( QLatin1String(
".ics") );
105 tmp.setAutoRemove(
false );
107 FileStorage storage( cal, tmp.fileName() );
109 openComposer( KUrl( tmp.fileName() ) );
111 KABC::Addressee::List::ConstIterator it;
113 KABC::Addressee::List::ConstIterator end(list.constEnd());
114 for ( it = list.constBegin(); it != end; ++it ) {
115 to.append( ( *it ).fullEmail() );
117 openComposer( to.join( QLatin1String(
", ") ) );
120 kWarning() << QString::fromLatin1(
"Cannot handle drop events of type '%1'." ).arg( QLatin1String(de->format()) );
126 Q_ASSERT( m_instance );
128 if ( attach.isValid() ) {
129 m_instance->newMessage( QString(), QString(), QString(),
false,
true, QString(), attach.isLocalFile() ?
130 attach.toLocalFile() : attach.path() );
132 m_instance->newMessage( QString(), QString(), QString(),
false,
true, QString(), QString() );
140 Q_ASSERT( m_instance );
142 m_instance->newMessage( to, QString(), QString(),
false,
true, QString(), QString() );
148 openComposer( QString::null );
153 QDBusMessage message =
154 QDBusMessage::createMethodCall( QLatin1String(
"org.kde.kmail"), QLatin1String(
"/KMail"),
155 QLatin1String(
"org.kde.kmail.kmail"),
156 QLatin1String(
"checkMail" ));
157 QDBusConnection::sessionBus().send( message );
168 if ( serviceType == QLatin1String(
"DBUS/Mailer" ) ) {
178 const QString file = KStandardDirs::locate(
"data", QLatin1String(
"kmail2/tips") );
184 KParts::ReadOnlyPart *part = loadPart();
189 m_instance =
new OrgKdeKmailKmailInterface(
190 QLatin1String(
"org.kde.kmail"), QLatin1String(
"/KMail"), QDBusConnection::sessionBus() );
197 return QStringList()<<QLatin1String(
"new_message" );
202 return mUniqueAppWatcher->isRunningStandalone();
212 #include "../../../kmail/kmail_options.h"
215 KCmdLineArgs::addCmdLineOptions( kmail_options() );
221 (void)plugin()->part();
222 org::kde::kmail::kmail kmail( QLatin1String(
"org.kde.kmail"), QLatin1String(
"/KMail"), QDBusConnection::sessionBus() );
223 QDBusReply<bool> reply = kmail.handleCommandLine(
false );
225 if ( reply.isValid() ) {
226 bool handled = reply;
228 return KontactInterface::UniqueAppHandler::newInstance();
236 org::kde::kmail::kmail kmail( QLatin1String(
"org.kde.kmail"), QLatin1String(
"/KMail"), QDBusConnection::sessionBus() );
237 QDBusReply<bool> canClose = kmail.canQueryClose();
241 #include "kmail_plugin.moc"
virtual bool queryClose() const
virtual KParts::ReadOnlyPart * createPart()
void openComposer(const KUrl &attach=KUrl())
virtual void loadCommandLineOptions()
static MailList fromMimeData(const QMimeData *md)
bool isRunningStandalone() const
void processDropEvent(QDropEvent *)
virtual int newInstance()
static bool canDecode(const QMimeData *md)
QStringList invisibleToolbarActions() const
bool createDBUSInterface(const QString &serviceType)
bool canDecodeMimeData(const QMimeData *) const
virtual KontactInterface::Summary * createSummaryWidget(QWidget *parent)