summaryrefslogtreecommitdiffstats
path: root/kommander/pluginmanager/main.cpp
blob: 745619250c148f8a8e17dedd923ac73597fcae52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/***************************************************************************
                          main.cpp  -  Kommander plugin manager interface
                             -------------------
    begin                : Tue Aug 13 09:31:50 EST 2002
    copyright            : (C) 2004 Marc Britton <consume@optushome.com.au>
                           (C) 2005 Michal Rudolf <mrudolf@kdewebdev.org>
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

/* KDE INCLUDES */
#include <kcmdlineargs.h>
#include <kaboutdata.h>
#include <klocale.h>
#include <kurl.h>
#include <tqapplication.h>
#include <tqobject.h>
#include <kapplication.h>

/* QT INCLUDES */
#include <tqstringlist.h>

/* OTHER INCLUDES */
#include "pluginmanager.h"
#include "mainwindow.h"
#include "kommanderversion.h"

#include <iostream>
using namespace std;

static const char *description =
	I18N_NOOP("kmdr-plugins is a component of the Kommander dialog system that manages installed plugins."); 
// INSERT A DESCRIPTION FOR YOUR APPLICATION HERE


static KCmdLineOptions options[] =
{
  { "a", 0, 0},
  { "add <file>", I18N_NOOP("Register given library"), 0},      
  { "r", 0, 0},
  { "remove <file>", I18N_NOOP("Remove given library"), 0},      
  { "c", 0, 0},
  { "check", I18N_NOOP("Check all installed plugins and remove those missing"), 0},
  { "l", 0, 0},
  { "list", I18N_NOOP("List all installed plugins"), 0},
  KCmdLineLastOption
};

int main(int argc, char *argv[])
{
  KLocale::setMainCatalogue("kommander");
  KAboutData aboutData( "kmdr-plugins", I18N_NOOP("Kommander Plugin Manager"),
    KOMMANDER_VERSION, description, KAboutData::License_GPL,
    "(C) 2004-2005 Kommander authors");
  aboutData.addAuthor("Marc Britton", "Original author", "consume@optusnet.com.au");
  aboutData.addAuthor("Eric Laffoon", "Project manager", "eric@kdewebdev.org");
  aboutData.addAuthor("Michal Rudolf", "Current maintainer", "mrudolf@kdewebdev.org");
  KCmdLineArgs::init(argc, argv, &aboutData);
  KCmdLineArgs::addCmdLineOptions(options); // Add our own options.

  KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
  KApplication app;
  
  if (!args->getOption("add").isNull() || !args->getOption("remove").isNull() || args->isSet("check")  || args->isSet("list"))
  {
    PluginManager P;
    if (args->isSet("check"))
      P.verify();
    
    QCStringList items = args->getOptionList("add");
    for (QCStringList::ConstIterator it = items.begin(); it != items.end(); ++it)
      if (!P.add(*it))
        cerr << i18n("Error adding plugin '%1'").arg(*it).local8Bit();
    
    items = args->getOptionList("remove");
    for (QCStringList::ConstIterator it = items.begin(); it != items.end(); ++it)
      if (!P.remove(*it))
        cerr << i18n("Error removing plugin '%1'").arg(*it).local8Bit();
    
    if (args->isSet("list"))
    {
      TQStringList plugins = P.items();
      for (TQStringList::ConstIterator it = plugins.begin(); it != plugins.end(); ++it)
        cout << (*it).local8Bit() << "\n";
    }
  }
  else 
  {
    MainWindow *mw = new MainWindow();
    app.setMainWidget(mw);
    mw->show();
    return app.exec();
  }
}