28#include <tqdragobject.h>
30#include <tdeapplication.h>
31#include <tdeabc/vcardconverter.h>
35#include <kgenericfactory.h>
36#include <kiconloader.h>
37#include <tdemessagebox.h>
38#include <kstandarddirs.h>
39#include <tdetempfile.h>
41#include <dcopclient.h>
43#include <libtdepim/kvcarddrag.h>
44#include <libtdepim/maillistdrag.h>
45#include <libtdepim/kpimprefs.h>
47#include <libkcal/calendarlocal.h>
48#include <libkcal/icaldrag.h>
51#include "summarywidget.h"
52#include "korganizerplugin.h"
53#include "korg_uniqueapp.h"
55typedef KGenericFactory< KOrganizerPlugin, Kontact::Core > KOrganizerPluginFactory;
56K_EXPORT_COMPONENT_FACTORY( libkontact_korganizerplugin,
57 KOrganizerPluginFactory(
"kontact_korganizerplugin" ) )
59KOrganizerPlugin::KOrganizerPlugin( Kontact::Core *core, const
char *, const TQStringList& )
60 : Kontact::Plugin( core, core,
"korganizer" ),
64 setInstance( KOrganizerPluginFactory::instance() );
65 instance()->iconLoader()->addAppDir(
"tdepim");
67 insertNewAction(
new TDEAction( i18n(
"New Event..." ),
"newappointment",
68 CTRL+SHIFT+Key_E,
this, TQ_SLOT( slotNewEvent() ), actionCollection(),
71 insertSyncAction(
new TDEAction( i18n(
"Synchronize Calendar" ),
"reload",
72 0,
this, TQ_SLOT( slotSyncEvents() ), actionCollection(),
73 "korganizer_sync" ) );
79KOrganizerPlugin::~KOrganizerPlugin()
90 return new SummaryWidget(
this, parent );
95 KParts::ReadOnlyPart *
part = loadPart();
100 mIface =
new KCalendarIface_stub(
dcopClient(),
"kontact",
"CalendarIface" );
107 TQString file = ::locate(
"data",
"korganizer/tips");
113 TQStringList invisible;
114 invisible +=
"new_event";
115 invisible +=
"new_todo";
116 invisible +=
"new_journal";
118 invisible +=
"view_todo";
119 invisible +=
"view_journal";
125 interface()->showEventView();
128KCalendarIface_stub *KOrganizerPlugin::interface()
137void KOrganizerPlugin::slotNewEvent()
139 interface()->openEventEditor(
"" );
142void KOrganizerPlugin::slotSyncEvents()
144 DCOPRef ref(
"korganizer",
"KOrganizerIface" );
145 ref.send(
"syncAllResources" );
148bool KOrganizerPlugin::createDCOPInterface(
const TQString& serviceType )
150 kdDebug(5602) << k_funcinfo << serviceType << endl;
151 if ( serviceType ==
"DCOP/Organizer" || serviceType ==
"DCOP/Calendar" ) {
161 return mUniqueAppWatcher->isRunningStandalone();
164bool KOrganizerPlugin::canDecodeDrag( TQMimeSource *mimeSource )
166 return TQTextDrag::canDecode( mimeSource ) ||
167 KPIM::MailListDrag::canDecode( mimeSource );
170void KOrganizerPlugin::processDropEvent( TQDropEvent *event )
172 TDEABC::Addressee::List list;
173 if ( KVCardDrag::decode( event, list ) ) {
174 TQStringList attendees;
175 TDEABC::Addressee::List::Iterator it;
176 for ( it = list.begin(); it != list.end(); ++it ) {
177 TQString email = (*it).fullEmail();
178 if ( email.isEmpty() ) {
179 attendees.append( (*it).realName() +
"<>" );
181 attendees.append( email );
184 interface()->openEventEditor( i18n(
"Meeting" ), TQString(), TQString(),
190 KCal::CalendarLocal cal( KPimPrefs::timezone() );
192 KCal::Incidence::List incidences = cal.incidences();
193 if ( !incidences.isEmpty() ) {
195 KCal::Incidence *i = incidences.first();
197 if (
dynamic_cast<KCal::Journal*
>( i ) )
198 summary = i18n(
"Note: %1" ).arg( i->
summary() );
201 interface()->openEventEditor( summary, i->
description(), TQString() );
209 if ( TQTextDrag::decode( event, text ) ) {
210 kdDebug(5602) <<
"DROP:" << text << endl;
211 interface()->openEventEditor( text );
215 KPIM::MailList mails;
216 if ( KPIM::MailListDrag::decode( event, mails ) ) {
217 if ( mails.count() != 1 ) {
218 KMessageBox::sorry( core(),
219 i18n(
"Drops of multiple mails are not supported." ) );
221 KPIM::MailSummary mail = mails.first();
222 TQString txt = i18n(
"From: %1\nTo: %2\nSubject: %3").arg( mail.from() )
223 .arg( mail.to() ).arg( mail.subject() );
226 tf.setAutoDelete(
true );
227 TQString uri = TQString::fromLatin1(
"kmail:") + TQString::number( mail.serialNumber() );
228 tf.file()->writeBlock( event->encodedData(
"message/rfc822" ) );
230 interface()->openEventEditor( i18n(
"Mail: %1").arg( mail.subject() ), txt,
231 uri, tf.name(), TQStringList(),
"message/rfc822" );
236 KMessageBox::sorry( core(), i18n(
"Cannot handle drop events of type '%1'.")
237 .arg( event->format() ) );
241 KOrganizerIface_stub stub( kapp->dcopClient(),
"korganizer",
"KOrganizerIface" );
242 bool canClose=stub.canQueryClose();
246void KOrganizerPlugin::loadProfile(
const TQString& directory )
248 DCOPRef ref(
"korganizer",
"KOrganizerIface" );
249 ref.send(
"loadProfile", directory );
252void KOrganizerPlugin::saveToProfile(
const TQString& directory )
const
254 DCOPRef ref(
"korganizer",
"KOrganizerIface" );
255 ref.send(
"saveToProfile", directory );
258#include "korganizerplugin.moc"
static bool canDecode(TQMimeSource *)
static bool decode(TQMimeSource *e, Calendar *cal)
TQString description() const
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 void select()
This function is called when the plugin is selected by the user before the widget of the KPart belong...
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.
If the standalone application is running by itself, we need to watch for when the user closes it,...