Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / workspace / khotkeys / update / update.cpp
blob4746ef2bd8d7c50a09eb228e51d3cef2201d1d32
1 /****************************************************************************
3 KHotKeys
5 Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
7 Distributed under the terms of the GNU General Public License version 2.
9 ****************************************************************************/
11 #define _UPDATE_CPP_
13 #include <config-workspace.h>
15 #include <kapplication.h>
16 #include <kcmdlineargs.h>
17 #include <kstandarddirs.h>
18 #include <kconfig.h>
19 #include <kdebug.h>
20 #include <QtDBus/QtDBus>
22 #include "khotkeysiface.h"
24 #include <settings.h>
26 using namespace KHotKeys;
28 int main( int argc, char* argv[] )
30 KCmdLineArgs::init( argc, argv, "khotkeys_update", 0, ki18n("KHotKeys Update"), "1.0" ,
31 ki18n("KHotKeys update utility"));
33 KCmdLineOptions options;
34 options.add("id <id>", ki18n("Id of the script to add to khotkeysrc."));
35 KCmdLineArgs::addCmdLineOptions( options );
36 KApplication app( true ); // X11 connection is necessary for KKey* stuff :-/
37 KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
38 QString id = args->getOption( "id" );
39 QString file = KStandardDirs::locate( "data", "khotkeys/" + id + ".khotkeys" );
40 if( file.isEmpty())
42 kWarning() << "File " << id << " not found!" ;
43 return 1;
45 init_global_data( false, &app );
46 Settings settings;
47 settings.read_settings( true );
48 KConfig cfg( file );
49 if( !settings.import( cfg, false ))
51 kWarning() << "Import of " << id << " failed!" ;
52 return 2;
54 settings.write_settings();
55 QDBusConnection bus = QDBusConnection::sessionBus();
56 if( bus.interface()->isServiceRegistered( "org.kde.khotkeys" ))
58 org::kde::khotkeys iface("org.kde.khotkeys", "/KHotKeys", bus);
59 iface.reread_configuration();
60 kDebug( 1217 ) << "telling khotkeys daemon to reread configuration";
62 return 0;