示例#1
0
//--------------------------------------------------
// Initialize libs
//--------------------------------------------------
int init(int argc, char** argv)
{
  int err = ERR_OK;
  char buf1[250];

  if(argc <= 1) {
    //printUsage();
    exit(0);
  }
  // init DigiDoc library
  initDigiDocLib();
#ifdef WIN32
  // find out program home if invoked with a long command line
  memset(buf1, 0, sizeof(buf1));
  getFileNamePath(argv[0], buf1, sizeof(buf1));
  if(strlen(buf1)) {
    strncat(buf1, "digidoc.ini", sizeof(buf1));
    err = initConfigStore(buf1);
  } else
    err = initConfigStore(NULL);
#else
  // read in config file
  err = initConfigStore(NULL);
#endif
  return err;
}
示例#2
0
FLDigiDoc::FLDigiDoc(const QString &configfile)
{

  int err = ERR_OK;
  initDigiDocLib();
  if (!configfile.isEmpty()) {
    err = initConfigStore(NULL);
    if (err == ERR_OK)
      err = readConfigFile(configfile.latin1(), ITEM_TYPE_PRIVATE);
    if (err != ERR_OK)
      qWarning("FLDigiDoc:" + QString(getErrorString(err)));
  }
}
示例#3
0
Application::Application( int &argc, char **argv )
:	Common( argc, argv )
,	d( new ApplicationPrivate )
{
	QStringList args = arguments();
	args.removeFirst();
#ifndef Q_OS_MAC
	if( isRunning() )
	{
		sendMessage( args.join( "\", \"" ) );
		return;
	}
	connect( this, SIGNAL(messageReceived(QString)), SLOT(parseArgs(QString)) );
#endif

	setApplicationName( APP );
	setApplicationVersion( QString( "%1.%2.%3.%4" )
		.arg( MAJOR_VER ).arg( MINOR_VER ).arg( RELEASE_VER ).arg( BUILD_VER ) );
	setOrganizationDomain( DOMAINURL );
	setOrganizationName( ORG );
	setWindowIcon( QIcon( ":/images/crypto_128x128.png" ) );

	// Actions
	d->closeAction = new QAction( this );
	d->closeAction->setShortcut( Qt::CTRL + Qt::Key_W );
	connect( d->closeAction, SIGNAL(triggered()), SLOT(closeWindow()) );

	d->newAction = new QAction( this );
	d->newAction->setShortcut( Qt::CTRL + Qt::Key_N );
	connect( d->newAction, SIGNAL(triggered()), SLOT(parseArgs()) );

#if defined(Q_OS_MAC)
	setQuitOnLastWindowClosed( false );

	d->bar = new MacMenuBar;
	d->bar->addAction( MacMenuBar::AboutAction, this, SLOT(showAbout()) );
	d->bar->addAction( MacMenuBar::PreferencesAction, this, SLOT(showSettings()) );
	d->bar->fileMenu()->addAction( d->newAction );
	d->bar->fileMenu()->addAction( d->closeAction );
	d->bar->dockMenu()->addAction( d->newAction );
#endif

	installTranslator( d->appTranslator = new QTranslator( this ) );
	installTranslator( d->commonTranslator = new QTranslator( this ) );
	installTranslator( d->qtTranslator = new QTranslator( this ) );
	loadTranslation( Settings::language() );

	initDigiDocLib();
	QString ini = QString( "%1/digidoc.ini" ).arg( applicationDirPath() );
	if( QFileInfo( ini ).isFile() )
		initConfigStore( ini.toUtf8() );
	else
		initConfigStore( NULL );

	Poller::ApiType api = Poller::PKCS11;
#ifdef Q_OS_WIN
	QString provider;
	QSettings reg( "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography\\Calais\\SmartCards", QSettings::NativeFormat );
	Q_FOREACH( const QString &group, reg.childGroups() )
	{
		if( group.contains( "esteid", Qt::CaseInsensitive ) )
		{
			provider = reg.value( group + "/" + "Crypto Provider" ).toString();
			break;
		}
	}
	if( QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA && provider != "EstEID Card CSP" )
		api = Poller::CNG;
	if( args.contains("-capi") && QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA )
		showWarning( tr("CAPI parameter is not supported on Windows Vista and newer") );
	else if( args.contains("-capi") )
		api = Poller::CAPI;
	if( args.contains("-cng") ) api = Poller::CNG;
#endif
	if( args.contains("-pkcs11") ) api = Poller::PKCS11;
	d->poller = new Poller( api, this );
	parseArgs( args );
}