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"
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 )
80 KVCardDrag::canDecode( qms ) );
83void KMailPlugin::processDropEvent( TQDropEvent * de )
85 kdDebug() << k_funcinfo << endl;
86 CalendarLocal cal( TQString::fromLatin1(
"UTC") );
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(
", ") );
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" ) {
153 TQString file = ::locate(
"data",
"kmail/tips");
159 KParts::ReadOnlyPart *
part = loadPart();
160 if ( !
part )
return 0;
162 mStub =
new KMailIface_stub(
dcopClient(),
"kmail",
"KMailIface" );
169 return TQStringList(
"new_message" );
174 return mUniqueAppWatcher->isRunningStandalone();
179 return new SummaryWidget(
this, parent );
184#include "../../../kmail/kmail_options.h"
187 TDECmdLineArgs::addCmdLineOptions( kmail_options );
193 (void)plugin()->part();
194 DCOPRef kmail(
"kmail",
"KMailIface" );
195 DCOPReply reply = kmail.call(
"handleCommandLine",
false );
196 if ( reply.isValid() ) {
197 bool handled = reply;
206 KMailIface_stub stub( kapp->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"
static bool canDecode(TQMimeSource *)
static bool decode(TQMimeSource *e, Calendar *cal)
static bool canDecode(TQMimeSource *)
static bool decode(TQMimeSource *e, Calendar *cal)
KParts::ReadOnlyPart * part()
You can use this method if you need to access the current part.
DCOPClient * dcopClient() const
Retrieve the current DCOP Client for the plugin.
virtual TQStringList invisibleToolbarActions() const
Returns a list of action name which shall be hidden in the main toolbar.
virtual bool isRunningStandalone()
Reimplement this method and return whether a standalone application is still running This is only req...
virtual bool queryClose() const
Reimplement this method if you want to add checks before closing down the main kontact window.
virtual TQString tipFile() const
Reimplement this method and return the a path relative to "data" to the tips file.
virtual KParts::ReadOnlyPart * createPart()=0
Reimplement and return the part here.
Summary widget for display in the Summary View plugin.
Used by UniqueAppWatcher below, to create the above UniqueAppHandler object when necessary.
virtual void loadCommandLineOptions()=0
This must be reimplemented so that app-specific command line options can be parsed.
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,...