Changeset View
Changeset View
Standalone View
Standalone View
src/smartcard/readerstatus.cpp
Show First 20 Lines • Show All 219 Lines • ▼ Show 20 Line(s) | |||||
220 | 220 | | |||
221 | static const std::string scd_getattr_status(std::shared_ptr<Context> &gpgAgent, const char *what, Error &err) | 221 | static const std::string scd_getattr_status(std::shared_ptr<Context> &gpgAgent, const char *what, Error &err) | ||
222 | { | 222 | { | ||
223 | std::string cmd = "SCD GETATTR "; | 223 | std::string cmd = "SCD GETATTR "; | ||
224 | cmd += what; | 224 | cmd += what; | ||
225 | return gpgagent_status(gpgAgent, cmd.c_str(), err); | 225 | return gpgagent_status(gpgAgent, cmd.c_str(), err); | ||
226 | } | 226 | } | ||
227 | 227 | | |||
228 | static const std::string gpgagent_data(std::shared_ptr<Context> &gpgAgent, const char *what, Error &err) | | |||
229 | { | | |||
230 | const std::unique_ptr<DefaultAssuanTransaction> t = gpgagent_transact(gpgAgent, what, err); | | |||
231 | if (t.get()) { | | |||
232 | return t->data(); | | |||
233 | } else { | | |||
234 | return std::string(); | | |||
235 | } | | |||
236 | } | | |||
237 | | ||||
238 | static void handle_openpgp_card(std::shared_ptr<Card> &ci, std::shared_ptr<Context> &gpg_agent) | 228 | static void handle_openpgp_card(std::shared_ptr<Card> &ci, std::shared_ptr<Context> &gpg_agent) | ||
239 | { | 229 | { | ||
240 | Error err; | 230 | Error err; | ||
241 | auto ret = new OpenPGPCard(); | 231 | auto ret = new OpenPGPCard(); | ||
242 | ret->setSerialNumber(ci->serialNumber()); | 232 | ret->setSerialNumber(ci->serialNumber()); | ||
243 | 233 | | |||
244 | const auto info = gpgagent_statuslines(gpg_agent, "SCD LEARN --keypairinfo", err); | 234 | const auto info = gpgagent_statuslines(gpg_agent, "SCD LEARN --keypairinfo", err); | ||
245 | if (err.code()) { | 235 | if (err.code()) { | ||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Line(s) | 244 | { | |||
303 | if (keyPairInfos.empty()) { | 293 | if (keyPairInfos.empty()) { | ||
304 | return; | 294 | return; | ||
305 | } | 295 | } | ||
306 | nkCard->setKeyPairInfo(keyPairInfos); | 296 | nkCard->setKeyPairInfo(keyPairInfos); | ||
307 | } | 297 | } | ||
308 | 298 | | |||
309 | static std::shared_ptr<Card> get_card_status(unsigned int slot, std::shared_ptr<Context> &gpg_agent) | 299 | static std::shared_ptr<Card> get_card_status(unsigned int slot, std::shared_ptr<Context> &gpg_agent) | ||
310 | { | 300 | { | ||
311 | Q_UNUSED(gpgagent_data); | | |||
312 | qCDebug(KLEOPATRA_LOG) << "get_card_status(" << slot << ',' << gpg_agent.get() << ')'; | 301 | qCDebug(KLEOPATRA_LOG) << "get_card_status(" << slot << ',' << gpg_agent.get() << ')'; | ||
313 | auto ci = std::shared_ptr<Card> (new Card()); | 302 | auto ci = std::shared_ptr<Card> (new Card()); | ||
314 | if (slot != 0 || !gpg_agent) { | 303 | if (slot != 0 || !gpg_agent) { | ||
315 | // In the future scdaemon should support multiple slots but | 304 | // In the future scdaemon should support multiple slots but | ||
316 | // not yet (2.1.18) | 305 | // not yet (2.1.18) | ||
317 | return ci; | 306 | return ci; | ||
318 | } | 307 | } | ||
319 | 308 | | |||
▲ Show 20 Lines • Show All 367 Lines • Show Last 20 Lines |