27#include <tdeapplication.h>
29#include <kgenericfactory.h>
30#include <kiconloader.h>
31#include <tdeparts/componentfactory.h>
32#include <tdestandarddirs.h>
33#include <dcopclient.h>
34#include <tdetempfile.h>
36#include <tdeabc/addressee.h>
38#include <libkcal/vcaldrag.h>
39#include <libkcal/icaldrag.h>
40#include <libkcal/calendarlocal.h>
42#include <libtdepim/kvcarddrag.h>
44#include <kmail/kmail_part.h>
45#include <kmail/kmkernel.h>
48#include "summarywidget.h"
50#include "kmail_plugin.h"
54typedef KGenericFactory<KMailPlugin, Kontact::Core> KMailPluginFactory;
55K_EXPORT_COMPONENT_FACTORY( libkontact_kmailplugin,
56 KMailPluginFactory(
"kontact_kmailplugin" ) )
58KMailPlugin::KMailPlugin(Kontact::Core *core, const
char *, const TQStringList& )
59 : Kontact::Plugin( core, core, "kmail" ),
62 setInstance( KMailPluginFactory::instance() );
64 insertNewAction(
new TDEAction( i18n(
"New Message..." ),
"mail-message-new",
65 CTRL+SHIFT+Key_M,
this, TQ_SLOT( slotNewMail() ), actionCollection(),
68 insertSyncAction(
new TDEAction( i18n(
"Synchronize Mail" ),
"reload",
69 0,
this, TQ_SLOT( slotSyncFolders() ), actionCollection(),
76bool KMailPlugin::canDecodeDrag( TQMimeSource *qms )
78 return ( ICalDrag::canDecode( qms ) ||
79 VCalDrag::canDecode( qms ) ||
80 KVCardDrag::canDecode( qms ) );
83void KMailPlugin::processDropEvent( TQDropEvent * de )
85 kdDebug() << k_funcinfo << endl;
87 TDEABC::Addressee::List list;
89 if ( VCalDrag::decode( de, &cal ) || ICalDrag::decode( de, &cal ) ) {
90 KTempFile tmp( locateLocal(
"tmp",
"incidences-" ),
".ics" );
91 cal.save( tmp.name() );
92 openComposer( KURL::fromPathOrURL( tmp.name() ) );
94 else if ( KVCardDrag::decode( de, list ) ) {
95 TDEABC::Addressee::List::Iterator it;
97 for ( it = list.begin(); it != list.end(); ++it ) {
98 to.append( ( *it ).fullEmail() );
100 openComposer( to.join(
", ") );
105void KMailPlugin::openComposer(
const KURL& attach )
110 if ( attach.isValid() )
111 mStub->newMessage(
"",
"",
"",
false,
true, KURL(), attach );
113 mStub->newMessage(
"",
"",
"",
false,
true, KURL(), KURL() );
117void KMailPlugin::openComposer(
const TQString& to )
122 mStub->newMessage( to,
"",
"",
false,
true, KURL(), KURL() );
126void KMailPlugin::slotNewMail()
128 openComposer( TQString() );
131void KMailPlugin::slotSyncFolders()
133 DCOPRef ref(
"kmail",
"KMailIface" );
134 ref.send(
"checkMail" );
137KMailPlugin::~KMailPlugin()
141bool KMailPlugin::createDCOPInterface(
const TQString& serviceType )
143 if ( serviceType ==
"DCOP/ResourceBackend/IMAP" ) {
151TQString KMailPlugin::tipFile()
const
153 TQString file = ::locate(
"data",
"kmail/tips");
157KParts::ReadOnlyPart* KMailPlugin::createPart()
159 KParts::ReadOnlyPart *part = loadPart();
160 if ( !part )
return 0;
162 mStub =
new KMailIface_stub( dcopClient(),
"kmail",
"KMailIface" );
167TQStringList KMailPlugin::invisibleToolbarActions()
const
169 return TQStringList(
"new_message" );
172bool KMailPlugin::isRunningStandalone()
174 return mUniqueAppWatcher->isRunningStandalone();
179 return new SummaryWidget(
this, parent );
184#include "../../../kmail/kmail_options.h"
185void KMailUniqueAppHandler::loadCommandLineOptions()
187 TDECmdLineArgs::addCmdLineOptions( kmail_options );
190int KMailUniqueAppHandler::newInstance()
193 (void)plugin()->part();
194 DCOPRef kmail(
"kmail",
"KMailIface" );
195 DCOPReply reply = kmail.call(
"handleCommandLine",
false );
196 if ( reply.isValid() ) {
197 bool handled = reply;
205bool KMailPlugin::queryClose()
const {
206 KMailIface_stub stub( tdeApp->dcopClient(),
"kmail",
"KMailIface" );
207 bool canClose=stub.canQueryClose();
211void KMailPlugin::loadProfile(
const TQString& profileDirectory ) {
212 DCOPRef ref(
"kmail",
"KMailIface" );
213 ref.send(
"loadProfile", profileDirectory );
216void KMailPlugin::saveToProfile(
const TQString& profileDirectory ) {
217 DCOPRef ref(
"kmail",
"KMailIface" );
218 ref.send(
"saveToProfile", profileDirectory );
221#include "kmail_plugin.moc"
Summary widget for display in the Summary View plugin.
Used by UniqueAppWatcher below, to create the above UniqueAppHandler object when necessary.
virtual int newInstance()
We can't use k_dcop and dcopidl here, because the data passed to newInstance can't be expressed in te...
If the standalone application is running by itself, we need to watch for when the user closes it,...