26 #include <tdeaction.h>
27 #include <tdeapplication.h>
29 #include <kgenericfactory.h>
30 #include <kiconloader.h>
31 #include <tdeparts/componentfactory.h>
32 #include <kstandarddirs.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"
54 typedef KGenericFactory<KMailPlugin, Kontact::Core> KMailPluginFactory;
55 K_EXPORT_COMPONENT_FACTORY( libkontact_kmailplugin,
56 KMailPluginFactory(
"kontact_kmailplugin" ) )
58 KMailPlugin::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(),
76 bool KMailPlugin::canDecodeDrag( TQMimeSource *qms )
80 KVCardDrag::canDecode( qms ) );
83 void KMailPlugin::processDropEvent( TQDropEvent * de )
85 kdDebug() << k_funcinfo << endl;
87 TDEABC::Addressee::List list;
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(
", ") );
105 void KMailPlugin::openComposer(
const KURL& attach )
110 if ( attach.isValid() )
111 mStub->newMessage(
"",
"",
"",
false,
true, KURL(), attach );
113 mStub->newMessage(
"",
"",
"",
false,
true, KURL(), KURL() );
117 void KMailPlugin::openComposer(
const TQString& to )
122 mStub->newMessage( to,
"",
"",
false,
true, KURL(), KURL() );
126 void KMailPlugin::slotNewMail()
128 openComposer( TQString() );
131 void KMailPlugin::slotSyncFolders()
133 DCOPRef ref(
"kmail",
"KMailIface" );
134 ref.send(
"checkMail" );
137 KMailPlugin::~KMailPlugin()
141 bool KMailPlugin::createDCOPInterface(
const TQString& serviceType )
143 if ( serviceType ==
"DCOP/ResourceBackend/IMAP" ) {
151 TQString KMailPlugin::tipFile()
const
153 TQString file = ::locate(
"data",
"kmail/tips");
157 KParts::ReadOnlyPart* KMailPlugin::createPart()
159 KParts::ReadOnlyPart *part = loadPart();
160 if ( !part )
return 0;
162 mStub =
new KMailIface_stub( dcopClient(),
"kmail",
"KMailIface" );
167 TQStringList KMailPlugin::invisibleToolbarActions()
const
169 return TQStringList(
"new_message" );
172 bool KMailPlugin::isRunningStandalone()
174 return mUniqueAppWatcher->isRunningStandalone();
179 return new SummaryWidget(
this, parent );
184 #include "../../../kmail/kmail_options.h"
185 void KMailUniqueAppHandler::loadCommandLineOptions()
187 TDECmdLineArgs::addCmdLineOptions( kmail_options );
190 int 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;
205 bool KMailPlugin::queryClose()
const {
206 KMailIface_stub stub( kapp->dcopClient(),
"kmail",
"KMailIface" );
207 bool canClose=stub.canQueryClose();
211 void KMailPlugin::loadProfile(
const TQString& profileDirectory ) {
212 DCOPRef ref(
"kmail",
"KMailIface" );
213 ref.send(
"loadProfile", profileDirectory );
216 void KMailPlugin::saveToProfile(
const TQString& profileDirectory ) {
217 DCOPRef ref(
"kmail",
"KMailIface" );
218 ref.send(
"saveToProfile", profileDirectory );
221 #include "kmail_plugin.moc"
static bool canDecode(TQMimeSource *)
static bool decode(TQMimeSource *e, Calendar *cal)
static bool canDecode(TQMimeSource *)
static bool decode(TQMimeSource *e, Calendar *cal)
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,...