28 #include <tqdragobject.h>
30 #include <tdeapplication.h>
31 #include <tdeabc/vcardconverter.h>
32 #include <tdeaction.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"
55 typedef KGenericFactory< KOrganizerPlugin, Kontact::Core > KOrganizerPluginFactory;
56 K_EXPORT_COMPONENT_FACTORY( libkontact_korganizerplugin,
57 KOrganizerPluginFactory(
"kontact_korganizerplugin" ) )
59 KOrganizerPlugin::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" ) );
79 KOrganizerPlugin::~KOrganizerPlugin()
90 return new SummaryWidget(
this, parent );
93 KParts::ReadOnlyPart *KOrganizerPlugin::createPart()
95 KParts::ReadOnlyPart *part = loadPart();
100 mIface =
new KCalendarIface_stub( dcopClient(),
"kontact",
"CalendarIface" );
105 TQString KOrganizerPlugin::tipFile()
const
107 TQString file = ::locate(
"data",
"korganizer/tips");
111 TQStringList KOrganizerPlugin::invisibleToolbarActions()
const
113 TQStringList invisible;
114 invisible +=
"new_event";
115 invisible +=
"new_todo";
116 invisible +=
"new_journal";
118 invisible +=
"view_todo";
119 invisible +=
"view_journal";
123 void KOrganizerPlugin::select()
125 interface()->showEventView();
128 KCalendarIface_stub *KOrganizerPlugin::interface()
137 void KOrganizerPlugin::slotNewEvent()
139 interface()->openEventEditor(
"" );
142 void KOrganizerPlugin::slotSyncEvents()
144 DCOPRef ref(
"korganizer",
"KOrganizerIface" );
145 ref.send(
"syncAllResources" );
148 bool KOrganizerPlugin::createDCOPInterface(
const TQString& serviceType )
150 kdDebug(5602) << k_funcinfo << serviceType << endl;
151 if ( serviceType ==
"DCOP/Organizer" || serviceType ==
"DCOP/Calendar" ) {
159 bool KOrganizerPlugin::isRunningStandalone()
161 return mUniqueAppWatcher->isRunningStandalone();
164 bool KOrganizerPlugin::canDecodeDrag( TQMimeSource *mimeSource )
166 return TQTextDrag::canDecode( mimeSource ) ||
167 KPIM::MailListDrag::canDecode( mimeSource );
170 void 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(),
192 KCal::Incidence::List incidences = cal.incidences();
193 if ( !incidences.isEmpty() ) {
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() ) );
240 bool KOrganizerPlugin::queryClose()
const {
241 KOrganizerIface_stub stub( kapp->dcopClient(),
"korganizer",
"KOrganizerIface" );
242 bool canClose=stub.canQueryClose();
246 void KOrganizerPlugin::loadProfile(
const TQString& directory )
248 DCOPRef ref(
"korganizer",
"KOrganizerIface" );
249 ref.send(
"loadProfile", directory );
252 void 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
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,...