cleanup of connection management, new major version number 3, use static connection methods; refs #26, refs #28, refs #29
This commit is contained in:
@@ -93,7 +93,7 @@ class Commands: public cardos::Commands {
|
||||
}
|
||||
|
||||
void listReader() {
|
||||
_readers = _c.scan();
|
||||
_readers = pcsc::Connection::scan();
|
||||
std::cout<<"Found "<<_readers.size()<<" readers"
|
||||
<<(_readers.size()?":":".")<<std::endl;
|
||||
int i(0);
|
||||
@@ -107,7 +107,7 @@ class Commands: public cardos::Commands {
|
||||
if (_readers.size()<0) return;
|
||||
int num(-1);
|
||||
if (std::cin>>num && num>=0 && num<_readers.size()) {
|
||||
_reader = _c.reader(_readers[num]);
|
||||
_reader = pcsc::Connection::reader(_readers[num]);
|
||||
std::cout<<"Active Reader: "<<_readers[num]<<std::endl;
|
||||
} else throw std::runtime_error("no valid reader selected");
|
||||
}
|
||||
@@ -153,7 +153,6 @@ class Commands: public cardos::Commands {
|
||||
|
||||
private:
|
||||
|
||||
pcsc::Connection _c;
|
||||
pcsc::Connection::Strings _readers;
|
||||
|
||||
cardos::BerValues _ber;
|
||||
|
@@ -21,13 +21,10 @@
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
pcsc::Connection c;
|
||||
pcsc::Connection::Strings readers;
|
||||
|
||||
|
||||
void list() {
|
||||
pcsc::Connection c;
|
||||
pcsc::Connection::Strings readers(c.scan());
|
||||
pcsc::Connection::Strings readers(pcsc::Connection::scan());
|
||||
std::cout<<"Found "<<readers.size()<<" readers"
|
||||
<<(readers.size()?":":".")<<std::endl;
|
||||
int i(0);
|
||||
@@ -39,7 +36,7 @@ void list() {
|
||||
int main(int argc, char** argv) try {
|
||||
int reader(0);
|
||||
std::string pin;
|
||||
std::string path("3f005015");
|
||||
std::string path("3f00");
|
||||
std::string id("8888");
|
||||
std::string data("Hallo Welt");
|
||||
mrw::args::parse(argc, argv, "Write data to card.",
|
||||
@@ -64,27 +61,29 @@ int main(int argc, char** argv) try {
|
||||
mrw::args::decl::param_list()
|
||||
<<mrw::args::param(data, "text"))
|
||||
);
|
||||
pcsc::Connection c;
|
||||
pcsc::Connection::Strings readers(c.scan());
|
||||
pcsc::Connection::Strings readers(pcsc::Connection::scan());
|
||||
if (reader<0 || readers.size()<reader) {
|
||||
std::cerr<<"reader not found: "<<reader<<std::endl;
|
||||
return 1;
|
||||
}
|
||||
cardos::Commands cmd(c.reader(readers[reader]));
|
||||
//cardos::BerValues d(cmd.directory(path));
|
||||
cardos::Commands cmd(pcsc::Connection::reader(readers[reader]));
|
||||
cardos::Dir d(cmd, path);
|
||||
//cardos::BerValues d(cmd.readBerFile(path));
|
||||
//std::cout<<d.print()<<std::endl;
|
||||
//cardos::BerValues d(cmd.directory(path));
|
||||
std::cout<<"-----------------------------------------------------"<<std::endl
|
||||
<<d.print()<<std::endl
|
||||
<<"-----------------------------------------------------"<<std::endl;
|
||||
//std::string res(cmd.readBinary(path));
|
||||
//std::cout<<"HEX:"<<std::endl<<crypto::readable(res)<<std::endl;
|
||||
//std::cout<<"BER:"<<std::endl<<cardos::BerValues(res).print()<<std::endl;
|
||||
if (!pin.size()) {
|
||||
std::cout<<"PIN: ";
|
||||
std::cin>>pin;
|
||||
}
|
||||
if (pin.size()) cmd.logonTransport(pin);
|
||||
cmd.phaseControl();
|
||||
cmd.createBinary(path, id, data);
|
||||
cmd.phaseControl();
|
||||
// if (!pin.size()) {
|
||||
// std::cout<<"PIN: ";
|
||||
// std::cin>>pin;
|
||||
// }
|
||||
// if (pin.size()) cmd.logonTransport(pin);
|
||||
// cmd.phaseControl();
|
||||
// cmd.createBinary(path, id, data);
|
||||
// cmd.phaseControl();
|
||||
return 0;
|
||||
} catch (std::exception& x) {
|
||||
std::cerr<<"ERROR: "<<x.what()<<std::endl;
|
||||
|
@@ -36,13 +36,16 @@ openssl_ssl_demo_SOURCES = openssl-ssl-demo.cxx
|
||||
openssl_engine_demo_SOURCES = openssl-engine-demo.cxx
|
||||
cardos_demo_SOURCES = cardos-demo.cxx
|
||||
suisse_id_demo_SOURCES = suisse-id-demo.cxx
|
||||
create_files_demo_SOURCES = create-files-demo.cxx
|
||||
# moc_suisse-id-demo.cxx
|
||||
suisse_id_demo_CXXFLAGS = ${QT_CFLAGS}
|
||||
suisse_id_demo_LDADD = ${QT_LIBS}
|
||||
suisse_id_demo_CXXFLAGS = ${QT_NETWORK_CFLAGS} -fPIC
|
||||
suisse_id_demo_LDADD = ${QT_NETWORK_LIBS}
|
||||
create_files_demo_SOURCES = create-files-demo.cxx
|
||||
|
||||
%_ui.hxx: %.ui
|
||||
uic -o $@ $<
|
||||
|
||||
moc_%.cxx: %.hxx
|
||||
moc -o $@ $<
|
||||
|
||||
CLEANFILES = moc_suisse-id-demo.cxx
|
||||
CLEANFILES = ${BUILT_SOURCES}
|
||||
MAINTAINERCLEANFILES = makefile.in
|
||||
|
88
doc/examples/moc_cardgui-model.cxx
Normal file
88
doc/examples/moc_cardgui-model.cxx
Normal file
@@ -0,0 +1,88 @@
|
||||
/****************************************************************************
|
||||
** Meta object code from reading C++ file 'cardgui-model.hxx'
|
||||
**
|
||||
** Created by: The Qt Meta Object Compiler version 67 (Qt 5.0.2)
|
||||
**
|
||||
** WARNING! All changes made in this file will be lost!
|
||||
*****************************************************************************/
|
||||
|
||||
#include "cardgui-model.hxx"
|
||||
#include <QtCore/qbytearray.h>
|
||||
#include <QtCore/qmetatype.h>
|
||||
#if !defined(Q_MOC_OUTPUT_REVISION)
|
||||
#error "The header file 'cardgui-model.hxx' doesn't include <QObject>."
|
||||
#elif Q_MOC_OUTPUT_REVISION != 67
|
||||
#error "This file was generated using the moc from 5.0.2. It"
|
||||
#error "cannot be used with the include files from this version of Qt."
|
||||
#error "(The moc has changed too much.)"
|
||||
#endif
|
||||
|
||||
QT_BEGIN_MOC_NAMESPACE
|
||||
struct qt_meta_stringdata_CardGuiModel_t {
|
||||
QByteArrayData data[1];
|
||||
char stringdata[14];
|
||||
};
|
||||
#define QT_MOC_LITERAL(idx, ofs, len) \
|
||||
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
|
||||
offsetof(qt_meta_stringdata_CardGuiModel_t, stringdata) + ofs \
|
||||
- idx * sizeof(QByteArrayData) \
|
||||
)
|
||||
static const qt_meta_stringdata_CardGuiModel_t qt_meta_stringdata_CardGuiModel = {
|
||||
{
|
||||
QT_MOC_LITERAL(0, 0, 12)
|
||||
},
|
||||
"CardGuiModel\0"
|
||||
};
|
||||
#undef QT_MOC_LITERAL
|
||||
|
||||
static const uint qt_meta_data_CardGuiModel[] = {
|
||||
|
||||
// content:
|
||||
7, // revision
|
||||
0, // classname
|
||||
0, 0, // classinfo
|
||||
0, 0, // methods
|
||||
0, 0, // properties
|
||||
0, 0, // enums/sets
|
||||
0, 0, // constructors
|
||||
0, // flags
|
||||
0, // signalCount
|
||||
|
||||
0 // eod
|
||||
};
|
||||
|
||||
void CardGuiModel::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
|
||||
{
|
||||
Q_UNUSED(_o);
|
||||
Q_UNUSED(_id);
|
||||
Q_UNUSED(_c);
|
||||
Q_UNUSED(_a);
|
||||
}
|
||||
|
||||
const QMetaObject CardGuiModel::staticMetaObject = {
|
||||
{ &QAbstractItemModel::staticMetaObject, qt_meta_stringdata_CardGuiModel.data,
|
||||
qt_meta_data_CardGuiModel, qt_static_metacall, 0, 0}
|
||||
};
|
||||
|
||||
|
||||
const QMetaObject *CardGuiModel::metaObject() const
|
||||
{
|
||||
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
|
||||
}
|
||||
|
||||
void *CardGuiModel::qt_metacast(const char *_clname)
|
||||
{
|
||||
if (!_clname) return 0;
|
||||
if (!strcmp(_clname, qt_meta_stringdata_CardGuiModel.stringdata))
|
||||
return static_cast<void*>(const_cast< CardGuiModel*>(this));
|
||||
return QAbstractItemModel::qt_metacast(_clname);
|
||||
}
|
||||
|
||||
int CardGuiModel::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
||||
{
|
||||
_id = QAbstractItemModel::qt_metacall(_c, _id, _a);
|
||||
if (_id < 0)
|
||||
return _id;
|
||||
return _id;
|
||||
}
|
||||
QT_END_MOC_NAMESPACE
|
@@ -3,15 +3,14 @@
|
||||
#include <iostream>
|
||||
|
||||
int main(int, char const*const*const argv) try {
|
||||
pcsc::Connection c;
|
||||
pcsc::Connection::Strings reader(c.scan());
|
||||
pcsc::Connection::Strings reader(pcsc::Connection::scan());
|
||||
std::cout<<"Library-Version: "<<pcsc::version()<<std::endl;
|
||||
std::cout<<"Suche PCSC-Reader ..."<<std::endl;
|
||||
if (!reader.size()) std::cout<<"Keine gefunden."<<std::endl;
|
||||
for (pcsc::Connection::Strings::const_iterator it(reader.begin());
|
||||
it!=reader.end(); ++it) {
|
||||
std::cout<<"Reader: "<<*it<<std::endl;
|
||||
pcsc::Connection::Reader::Status s(c.reader(*it)->status());
|
||||
pcsc::Connection::Reader::Status s(pcsc::Connection::reader(*it)->status());
|
||||
std::cout<<"Status = "<<s.state<<std::endl;
|
||||
std::cout<<"ATR = "<<crypto::hex(s.atr)<<std::endl;
|
||||
}
|
||||
|
Reference in New Issue
Block a user