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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
/***************************************************************************
* Copyright (C) 2002 by Wilco Greven <greven@kde.org> *
* Copyright (C) 2003 by Christophe Devriese *
* <Christophe.Devriese@student.kuleuven.ac.be> *
* Copyright (C) 2003 by Laurent Montel <montel@kde.org> *
* Copyright (C) 2003-2004 by Albert Astals Cid <tsdgeos@terra.es> *
* Copyright (C) 2004 by Andy Goossens <andygoossens@telenet.be> *
* *
* 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 "shell.h"
#include <tdeapplication.h>
#include <tdeaboutdata.h>
#include <tdecmdlineargs.h>
#include <tdeconfig.h>
#include <tdelocale.h>
#include <dcopclient.h>
#include <dcopref.h>
#include <kdebug.h>
static const char description[] =
I18N_NOOP("KPDF, a TDE PDF viewer based on XPDF");
static const char version[] = "0.5.10";
static TDECmdLineOptions options[] =
{
{ "new-instance", I18N_NOOP("Don't reuse existing instance"), 0 },
{ "+[URL]", I18N_NOOP("Document to open"), 0 },
TDECmdLineLastOption
};
int main(int argc, char** argv)
{
TDEAboutData about(
"kpdf",
I18N_NOOP("KPDF"),
version,
description,
TDEAboutData::License_GPL,
"(C) 2002 Wilco Greven, Christophe Devriese\n(C) 2004-2005 Albert Astals Cid, Enrico Ros");
about.addAuthor("Wilco Greven", 0, "greven@kde.org");
about.addAuthor("Christophe Devriese", 0, "oelewapperke@oelewapperke.org");
about.addAuthor("Laurent Montel", 0, "montel@kde.org");
about.addAuthor("Albert Astals Cid", I18N_NOOP("Current mantainer"), "astals11@terra.es");
about.addAuthor("Enrico Ros", 0, "eros.kde@email.it");
about.addCredit("Derek Noonburg", I18N_NOOP("Xpdf author"), 0, "http://www.foolabs.com/xpdf/");
about.addCredit("Marco Martin", I18N_NOOP("Icon"), 0, "m4rt@libero.it");
TDECmdLineArgs::init(argc, argv, &about);
TDECmdLineArgs::addCmdLineOptions( options );
TDEApplication app;
// see if we are starting with session management
if (app.isRestored())
{
RESTORE(KPDF::Shell);
} else {
// no session.. just start up normally
TDECmdLineArgs* args = TDECmdLineArgs::parsedArgs();
DCOPClient *client = tdeApp->dcopClient();
if (!client->attach())
{
kdError() << "KPDF::Shell cannot attach DCOP client" << endl;
return 2;
}
bool reuseKPDF;
if (args->isSet("new-instance"))
{
reuseKPDF = false;
}
else
{
TDEConfig cfg("kpdfpartrc");
cfg.setGroup("General");
reuseKPDF = cfg.readBoolEntry("OpenInExistingKPDF", false);
}
TQCString kpdfInstance = "";
TQCString regName = client->registerAs(tdeApp->name(), true);
if (reuseKPDF && args->count())
{
QCStringList allClients = client->registeredApplications();
for (int c = 0; c < allClients.count(); ++c)
{
if (allClients[c].left(5) == "kpdf-" && allClients[c] != regName)
{
kpdfInstance = allClients[c];
}
}
}
if (kpdfInstance.isEmpty())
{
KPDF::Shell* widget = new KPDF::Shell;
for (int i = 0; i < args->count(); ++i)
{
widget->openURL(args->url(i));
}
widget->show();
}
else
{
for (int i = 0; i < args->count(); ++i)
{
DCOPRef ref(kpdfInstance, "KPDFShellDCOPIface");
ref.call("openURL", args->url(i));
}
DCOPRef ref(kpdfInstance, "KPDF::Shell");
ref.call("raise");
return 1;
}
args->clear();
}
return app.exec();
}
|