summaryrefslogtreecommitdiffstats
path: root/src/main.cpp
blob: ac09a5dbc112c868b73a2f32c34abf60a34813c1 (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
/***************************************************************************
  main.cpp  -  description
  -------------------
begin                : Sat Dec  7 16:14:51 CET 2002
copyright            : (C) 2002 by Koos Vriezen
email                :
 ***************************************************************************/

/***************************************************************************
*                                                                         *
*   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.                                   *
*                                                                         *
 ***************************************************************************/
#include <unistd.h>

#include <config.h>
#include <kcmdlineargs.h>
#include <kaboutdata.h>
#include <klocale.h>
#include <kdemacros.h>
#include <dcopclient.h>

#include <tqguardedptr.h>
#include <tqfileinfo.h>
#include <tqtimer.h>

#include "kmplayer.h"

static const char description[] = I18N_NOOP("KMPlayer");


static TDECmdLineOptions options[] =
{
    { "+[File]", I18N_NOOP("file to open"), 0 },
    TDECmdLineLastOption
    // INSERT YOUR COMMANDLINE OPTIONS HERE
};

extern "C" {

    KDE_EXPORT int kdemain (int argc, char *argv[])
    {
        setsid ();

        TDEAboutData aboutData ("kmplayer", I18N_NOOP ("KMPlayer"),
                VERSION, description, TDEAboutData::License_GPL,
                "(c) 2002-2005, Koos Vriezen", 0, 0, "");
        aboutData.addAuthor( "Koos Vriezen",0, "");
        TDECmdLineArgs::init (argc, argv, &aboutData);
        TDECmdLineArgs::addCmdLineOptions (options); // Add our own options.

        KMPlayer::StringPool::init();

        TDEApplication app;
        TQGuardedPtr <KMPlayerApp> kmplayer;

        if (app.isRestored ()) {
            RESTORE (KMPlayerApp);
        } else {
            kmplayer = new KMPlayerApp ();
            kmplayer->show();

            TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();

            KURL url;
            if (args->count () == 1)
                url = args->url (0);
            if (args->count () > 1)
                for (int i = 0; i < args->count (); i++) {
                    KURL url = args->url (i);
                    if (url.url ().find ("://") < 0)
                        url = KURL (TQFileInfo (url.url ()).absFilePath ());
                    if (url.isValid ())
                        kmplayer->addURL (url);
                }
            kmplayer->openDocumentFile (url);
            args->clear ();
        }
        app.dcopClient()->registerAs("kmplayer");
        int retvalue = app.exec ();

        delete kmplayer;

        KMPlayer::StringPool::reset();

        return retvalue;
    }
}