33 #include <config-kleopatra.h>
45 #ifdef HAVE_USABLE_ASSUAN
69 #include <kleo/checksumdefinition.h>
71 #ifdef KDEPIM_MOBILE_UI
72 # include <kdeclarativeapplication.h>
76 #include <kcmdlineargs.h>
78 #include <kiconloader.h>
79 #include <ksplashscreen.h>
80 #include <kmessagebox.h>
82 #include <QTextDocument>
83 #include <QMessageBox>
87 #include <QThreadPool>
89 #include <gpgme++/global.h>
90 #include <gpgme++/error.h>
93 #include <boost/shared_ptr.hpp>
98 using namespace boost;
103 template <
typename T>
113 KIconLoader *
const il = KIconLoader::global();
119 #ifndef QT_NO_SPLASHSCREEN
120 class SplashScreen :
public KSplashScreen {
124 : KSplashScreen(
UserIcon_nocached(
"kleopatra_splashscreen" ), Qt::WindowStaysOnTopHint ),
132 if ( ev->
timerId() == m_timer.timerId() ) {
136 KSplashScreen::timerEvent( ev );
142 class SplashScreen {};
143 #endif // QT_NO_SPLASHSCREEN
146 #ifndef QT_NO_SPLASHSCREEN
147 splash.showMessage( i18n(
"Performing Self-Check...") );
152 #ifndef QT_NO_SPLASHSCREEN
157 #ifndef QT_NO_SPLASHSCREEN
163 #ifndef QT_NO_SPLASHSCREEN
164 splash.showMessage( i18nc(
"did not pass",
"Self-Check Failed") );
168 #ifndef QT_NO_SPLASHSCREEN
169 splash.showMessage( i18n(
"Self-Check Passed") );
180 #ifdef HAVE_USABLE_ASSUAN
181 QObject::connect( cmd, SIGNAL(finished()), server, SLOT(enableCryptoCommands()) );
185 #ifndef QT_NO_SPLASHSCREEN
186 splash->showMessage( i18n(
"Loading certificate cache...") );
192 #ifndef QT_NO_SPLASHSCREEN
193 splash->showMessage( i18n(
"Certificate cache loaded.") );
197 int main(
int argc,
char** argv )
202 const GpgME::Error gpgmeInitError = GpgME::initializeLibrary(0);
211 KCmdLineArgs::init(argc, argv, &aboutData);
213 #ifdef KDEPIM_MOBILE_UI
219 kDebug() <<
"Statup timing:" << timer.
elapsed() <<
"ms elapsed: Command line args created";
222 #ifdef KDEPIM_MOBILE_UI
223 KDeclarativeApplicationBase::postApplicationSetup();
226 kDebug() <<
"Startup timing:" << timer.
elapsed() <<
"ms elapsed: Application created";
228 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
230 if ( gpgmeInitError ) {
231 KMessageBox::sorry( 0, i18nc(
"@info",
232 "<para>The version of the <application>GpgME</application> library you are running against "
233 "is older than the one that the <application>GpgME++</application> library was built against.</para>"
234 "<para><application>Kleopatra</application> will not function in this setting.</para>"
235 "<para>Please ask your administrator for help in resolving this issue.</para>"),
236 i18nc(
"@title",
"GpgME Too Old") );
243 Kleo::ChecksumDefinition::setInstallPath( installPath );
247 #ifdef HAVE_USABLE_ASSUAN
251 kDebug() <<
"Startup timing:" << timer.
elapsed() <<
"ms elapsed: UiServer created";
254 &app, SLOT(openOrRaiseMainWindow()) );
257 &app, SLOT(openOrRaiseConfigDialog()) );
259 #define REGISTER( Command ) server.registerCommandFactory( boost::shared_ptr<Kleo::AssuanCommandFactory>( new Kleo::GenericAssuanCommandFactory<Kleo::Command> ) )
260 REGISTER( CreateChecksumsCommand );
261 REGISTER( DecryptCommand );
262 REGISTER( DecryptFilesCommand );
263 REGISTER( DecryptVerifyFilesCommand );
264 REGISTER( EchoCommand );
265 REGISTER( EncryptCommand );
266 REGISTER( EncryptFilesCommand );
267 REGISTER( EncryptSignFilesCommand );
268 REGISTER( ImportFilesCommand );
269 REGISTER( PrepEncryptCommand );
270 REGISTER( PrepSignCommand );
271 REGISTER( SelectCertificateCommand );
272 REGISTER( SignCommand );
273 REGISTER( SignEncryptFilesCommand );
274 REGISTER( SignFilesCommand );
275 #ifndef QT_NO_DIRMODEL
276 REGISTER( VerifyChecksumsCommand );
277 #endif // QT_NO_DIRMODEL
278 REGISTER( VerifyCommand );
279 REGISTER( VerifyFilesCommand );
283 kDebug() <<
"Startup timing:" << timer.
elapsed() <<
"ms elapsed: UiServer started";
286 const bool daemon = args->isSet(
"daemon");
287 if ( !daemon && app.isSessionRestored() ) {
291 #ifndef QT_NO_SPLASHSCREEN
293 if ( !( daemon || app.isSessionRestored() ) )
298 kDebug() <<
"Startup timing:" << timer.
elapsed() <<
"ms elapsed: SelfCheck completed";
300 #ifdef HAVE_USABLE_ASSUAN
305 kDebug() <<
"Startup timing:" << timer.
elapsed() <<
"ms elapsed: KeyCache loaded";
307 #ifndef QT_NO_SYSTEMTRAYICON
316 kDebug() <<
"Startup timing:" << timer.
elapsed() <<
"ms elapsed: new instance created";
317 #ifndef QT_NO_SPLASHSCREEN
319 #endif // QT_NO_SPLASHSCREEN
324 #ifdef HAVE_USABLE_ASSUAN
327 &app, SLOT(openOrRaiseMainWindow()) );
329 &app, SLOT(openOrRaiseConfigDialog()) );
332 server.waitForStopped();
333 }
catch (
const std::exception & e ) {
335 i18n(
"<qt>The Kleopatra GPG UI Server Module could not be initialized.<br/>"
336 "The error given was: <b>%1</b><br/>"
337 "You can use Kleopatra as a certificate manager, but cryptographic plugins that "
338 "rely on a GPG UI Server being present might not work correctly, or at all.</qt>",
340 #ifndef QT_NO_SYSTEMTRAYICON
static QPixmap UserIcon_nocached(const char *name)
int main(int argc, char **argv)
QThreadPool * globalInstance()
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
void setAutoDelete(bool on)
void setAutomaticMode(bool automatic)
void setIgnoreNewInstance(bool on)
QString fromUtf8(const char *str, int size)
static void fillKeyCache(SplashScreen *splash, Kleo::UiServer *server)
int exec(QFlags< QEventLoop::ProcessEventsFlag > flags)
static const int SPLASHSCREEN_TIMEOUT
const MainWindow * mainWindow() const
void setSplashScreen(KSplashScreen *splash)
static KCmdLineOptions commandLineOptions()
void startMonitoringSmartCard()
QString escape(const QString &plain)
void setFirstNewInstance(bool on)
static bool selfCheck(SplashScreen &splash)
QString gpg4winInstallPath()
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
static void setInstallPath(const QString &ip)