summaryrefslogtreecommitdiffstats
path: root/kbiff/main.cpp
blob: 0739461dbec8cc539bcd5d4ca5bd4ff1f4926313 (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
#include "kbiff.h"
#include "version.h"
#include <twin.h>
#include <kapp.h>
#include <tdelocale.h>
#include <tdecmdlineargs.h>
#include <tdeaboutdata.h>

#include "setupdlg.h"

static const char *description = 
  I18N_NOOP("Full featured mail notification utility.");

static TDECmdLineOptions option[] =
{
   { "secure", I18N_NOOP("Run in secure mode"), 0 },
   { "profile <profile>", I18N_NOOP("Use 'profile'"), 0 },
   { 0, 0, 0 }
};

extern "C" KDE_EXPORT int kdemain(int argc, char *argv[])
{
  TDEAboutData aboutData( "kbiff", I18N_NOOP("KBiff"),
      kbiff_version, description, TDEAboutData::License_GPL,
      "(c) 1998-2008, Kurt Granroth");
  aboutData.addAuthor("Kurt Granroth",0, "granroth@kde.org");
  TDECmdLineArgs::init( argc, argv, &aboutData );
  TDECmdLineArgs::addCmdLineOptions(option);

  TDEApplication app;
  KBiff kbiff(app.dcopClient());
  KBiffSetup* setup = 0;
  bool is_secure    = false;
  bool have_profile = false;
  TQString profile;

  app.setMainWidget(&kbiff);

  TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();

  is_secure = args->isSet("secure");

  if (args->isSet("profile"))
  {
    profile = args->getOption("profile");
    have_profile = true;
  }

  args->clear();

  // restore this app if it is
  if (kapp->isRestored())
    kbiff.readSessionConfig();
  else
  {
    // do we have the profile option?
    if (have_profile)
    {
      setup = new KBiffSetup(profile, is_secure);
    }
    else
    {
      setup = new KBiffSetup();

      if (!setup->exec())
      {
        delete setup;
        return 0;
      }
    }
    kbiff.processSetup(setup, true);

  }

  // check if we are docked (only if restored)
  if (kbiff.isDocked())
  {
    kapp->setTopWidget(new TQWidget);
    KWin::setSystemTrayWindowFor(kbiff.winId(), 0);
  }
  else
    kapp->setTopWidget(&kbiff);

  kbiff.show();

  return app.exec();
}