korg_uniqueapp.cpp
1/*
2 This file is part of KDE Kontact.
3
4 Copyright (c) 2003 David Faure <faure@kde.org>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21
22#include "korg_uniqueapp.h"
23#include "../../korganizer/korganizer_options.h"
24
25#include "core.h"
26#include <dcopref.h>
27#include <tdeapplication.h>
28#include <tdestartupinfo.h>
29#include <twin.h>
30
31void KOrganizerUniqueAppHandler::loadCommandLineOptions()
32{
33 TDECmdLineArgs::addCmdLineOptions( korganizer_options );
34}
35
36int KOrganizerUniqueAppHandler::newInstance()
37{
38 // Ensure part is loaded
39 (void)plugin()->part();
40 DCOPRef korganizer( "korganizer", "KOrganizerIface" );
41 korganizer.send( "handleCommandLine" );
42
43 // Bring korganizer's plugin to front
44 // This bit is duplicated from TDEUniqueApplication::newInstance()
45 if ( tdeApp->mainWidget() ) {
46 tdeApp->mainWidget()->show();
47 KWin::forceActiveWindow( tdeApp->mainWidget()->winId() );
48 TDEStartupInfo::appStarted();
49 }
50
51 // Then ensure the part appears in kontact.
52 // ALWAYS use the korganizer plugin; i.e. never show the todo nor journal
53 // plugins when creating a new instance via the command line, even if
54 // the command line options are empty; else we'd need to examine the
55 // options and then figure out which plugin we should show.
56 // kolab/issue3971
57 plugin()->core()->selectPlugin( "kontact_korganizerplugin" );
58 return 0;
59}