noconsole.patch 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. From e932e57c04a8e2af39624f1207c9411eb0e976db Mon Sep 17 00:00:00 2001
  2. From: root <you@example.com>
  3. Date: Tue, 15 Jun 2021 21:33:43 +0000
  4. Subject: [PATCH] No console
  5. ---
  6. include/QtCrypto/qca_support.h | 430 ---------------------------------
  7. src/CMakeLists.txt | 42 ++--
  8. 2 files changed, 21 insertions(+), 451 deletions(-)
  9. diff --git a/include/QtCrypto/qca_support.h b/include/QtCrypto/qca_support.h
  10. index 8e46bb7..2de8830 100644
  11. --- a/include/QtCrypto/qca_support.h
  12. +++ b/include/QtCrypto/qca_support.h
  13. @@ -497,436 +497,6 @@ private:
  14. Private *d;
  15. };
  16. -class ConsolePrivate;
  17. -class ConsoleReferencePrivate;
  18. -class ConsoleReference;
  19. -
  20. -/**
  21. - \class Console qca_support.h QtCrypto
  22. -
  23. - %QCA %Console system
  24. -
  25. - %QCA provides an API for asynchronous, event-based access to
  26. - the console and stdin/stdout, as these facilities are
  27. - otherwise not portable. The primary use of this system within
  28. - %QCA is for passphrase prompting in command-line applications,
  29. - using the tty console type.
  30. -
  31. - How it works: Create a %Console object for the type of console
  32. - desired, and then use ConsoleReference to act on the console.
  33. - Only one ConsoleReference may operate on a %Console at a time.
  34. -
  35. - A %Console object takes over either the physical console (Console::Tty
  36. - type) or stdin/stdout (Console::Stdio type). Only one of each type
  37. - may be created at a time.
  38. -
  39. - Whenever code is written that needs a tty or stdio object, the
  40. - code should first call one of the static methods (ttyInstance()
  41. - or stdioInstance()) to see if a console object for the desired
  42. - type exists already. If the object exists, use it. If it does
  43. - not exist, the rule is that the relevant code should create the
  44. - object, use the object, and then destroy the object when the
  45. - operation is completed.
  46. -
  47. - By following the above rule, you can write code that utilizes
  48. - a console without the application having to create some master
  49. - console object for you. Of course, if the application has
  50. - created a console then it will be used.
  51. -
  52. - The reason why there is a master console object is that it
  53. - is not guaranteed that all I/O will survive creation and
  54. - destruction of a console object. If you are using the Stdio
  55. - Type, then you probably want a long-lived console object. It
  56. - is possible to capture unprocessed I/O by calling
  57. - bytesLeftToRead or bytesLeftToWrite. However, it is not
  58. - expected that general console-needing code will call these
  59. - functions when utilizing a temporary console. Thus, an
  60. - application developer would need to create his own console
  61. - object, invoke the console-needing code, and then do his own
  62. - extraction of the unprocessed I/O if necessary. Another reason
  63. - to extract unprocessed I/O is if you need to switch from
  64. - %Console back to standard functions (e.g. fgets() ).
  65. -
  66. - \ingroup UserAPI
  67. -*/
  68. -class QCA_EXPORT Console : public QObject
  69. -{
  70. - Q_OBJECT
  71. -public:
  72. - /**
  73. - The type of console object
  74. - */
  75. - enum Type
  76. - {
  77. - Tty, ///< physical console
  78. - Stdio ///< stdin/stdout
  79. - };
  80. - /**
  81. - The type of I/O to use with the console object.
  82. - */
  83. - enum ChannelMode
  84. - {
  85. - Read, ///< Read only (equivalent to stdin)
  86. - ReadWrite ///< Read/write (equivalent to stdin and stdout)
  87. - };
  88. -
  89. - /**
  90. - The nature of the console operation
  91. - */
  92. - enum TerminalMode
  93. - {
  94. - Default, ///< use default terminal settings
  95. - Interactive ///< char-by-char input, no echo
  96. - };
  97. -
  98. - /**
  99. - Standard constructor
  100. -
  101. - Note that library code should not create a new Console object
  102. - without checking whether there is already a Console object of
  103. - the required Type. See the main documentation for Console for the
  104. - rationale for this.
  105. -
  106. - \param type the Type of Console object to create
  107. - \param cmode the ChannelMode (I/O type) to use
  108. - \param tmode the TerminalMode to use
  109. - \param parent the parent object for this object
  110. -
  111. - \sa ttyInstance() and stdioInstance for static methods that allow
  112. - you to test whether there is already a Console object of the
  113. - required Type, and if there is, obtain a reference to that object.
  114. - */
  115. - Console(Type type, ChannelMode cmode, TerminalMode tmode, QObject *parent = nullptr);
  116. - ~Console() override;
  117. -
  118. - /**
  119. - The Type of this Console object
  120. - */
  121. - Type type() const;
  122. -
  123. - /**
  124. - The ChannelMode of this Console object
  125. - */
  126. - ChannelMode channelMode() const;
  127. -
  128. - /**
  129. - The TerminalMode of this Console object
  130. - */
  131. - TerminalMode terminalMode() const;
  132. -
  133. - /**
  134. - Test whether standard input is redirected.
  135. -
  136. - \sa type() and channelMode()
  137. - */
  138. - static bool isStdinRedirected();
  139. -
  140. - /**
  141. - Test whether standard output is redirected.
  142. -
  143. - \sa type() and channelMode()
  144. - */
  145. - static bool isStdoutRedirected();
  146. -
  147. - /**
  148. - The current terminal-type console object
  149. -
  150. - \return null if there is no current Console
  151. - of this type, otherwise the Console to use
  152. - */
  153. - static Console *ttyInstance();
  154. -
  155. - /**
  156. - The current stdio-type console object
  157. -
  158. - \return null if there is no current Console
  159. - of this type, otherwise the Console to use
  160. - */
  161. - static Console *stdioInstance();
  162. -
  163. - /**
  164. - Release the Console
  165. -
  166. - This allows access to buffers containing any remaining data
  167. - */
  168. - void release();
  169. -
  170. - /**
  171. - Obtain remaining data from the Console, awaiting
  172. - a read operation
  173. - */
  174. - QByteArray bytesLeftToRead();
  175. -
  176. - /**
  177. - Obtain remaining data from the Console, awaiting
  178. - a write operation
  179. - */
  180. - QByteArray bytesLeftToWrite();
  181. -
  182. -private:
  183. - Q_DISABLE_COPY(Console)
  184. -
  185. - friend class ConsolePrivate;
  186. - ConsolePrivate *d;
  187. -
  188. - friend class ConsoleReference;
  189. -};
  190. -
  191. -/**
  192. - \class ConsoleReference qca_support.h QtCrypto
  193. -
  194. - Manager for a Console
  195. -
  196. - \note Only one %ConsoleReference object can be active at a time
  197. -
  198. - \ingroup UserAPI
  199. -*/
  200. -class QCA_EXPORT ConsoleReference : public QObject
  201. -{
  202. - Q_OBJECT
  203. -public:
  204. - /**
  205. - The security setting to use for the Console being managed.
  206. - */
  207. - enum SecurityMode
  208. - {
  209. - SecurityDisabled,
  210. - SecurityEnabled
  211. - };
  212. -
  213. - /**
  214. - Standard constructor
  215. -
  216. - \param parent the parent object for this object
  217. - */
  218. - ConsoleReference(QObject *parent = nullptr);
  219. - ~ConsoleReference() override;
  220. -
  221. - /**
  222. - Set the Console object to be managed, and start processing.
  223. -
  224. - You typically want to use Console::ttyInstance() or
  225. - Console::stdioInstance() to obtain the required Console
  226. - reference.
  227. -
  228. - \param console reference to the Console to be managed
  229. - \param mode the SecurityMode to use for this Console.
  230. -
  231. - \sa QCA::Console for more information on how to handle the
  232. - console aspects of your application or library code.
  233. - */
  234. - bool start(Console *console, SecurityMode mode = SecurityDisabled);
  235. -
  236. - /**
  237. - Stop processing, and release the Console
  238. - */
  239. - void stop();
  240. -
  241. - /**
  242. - The Console object managed by this object
  243. -
  244. - \sa start() to set the Console to be managed
  245. - */
  246. - Console *console() const;
  247. -
  248. - /**
  249. - The security mode setting for the Console object
  250. - managed by this object.
  251. -
  252. - \sa start() to set the SecurityMode
  253. - */
  254. - SecurityMode securityMode() const;
  255. -
  256. - /**
  257. - Read data from the Console.
  258. -
  259. - \param bytes the number of bytes to read. The default
  260. - is to read all available bytes
  261. -
  262. - \sa readSecure() for a method suitable for reading
  263. - sensitive data.
  264. - */
  265. - QByteArray read(int bytes = -1);
  266. -
  267. - /**
  268. - Write data to the Console.
  269. -
  270. - \param a the array of data to write to the Console
  271. -
  272. - \sa writeSecure() for a method suitable for writing
  273. - sensitive data.
  274. - */
  275. - void write(const QByteArray &a);
  276. -
  277. - /**
  278. - Read secure data from the Console
  279. -
  280. - \param bytes the number of bytes to read. The default
  281. - is to read all available bytes
  282. -
  283. - \sa read() which is suitable for non-sensitive data
  284. - */
  285. - SecureArray readSecure(int bytes = -1);
  286. -
  287. - /**
  288. - Write secure data to the Console
  289. -
  290. - \param a the array of data to write to the Console
  291. -
  292. - \sa write() which is suitable for non-sensitive data
  293. - */
  294. - void writeSecure(const SecureArray &a);
  295. -
  296. - /**
  297. - Close the write channel
  298. -
  299. - You only need to call this if writing is enabled
  300. - on the Console being managed.
  301. - */
  302. - void closeOutput();
  303. -
  304. - /**
  305. - The number of bytes available to read from the
  306. - Console being managed.
  307. - */
  308. - int bytesAvailable() const;
  309. -
  310. - /**
  311. - The number of bytes remaining to be written
  312. - to the Console being managed
  313. - */
  314. - int bytesToWrite() const;
  315. -
  316. -Q_SIGNALS:
  317. - /**
  318. - Emitted when there are bytes available to read from
  319. - the Console being managed
  320. - */
  321. - void readyRead();
  322. -
  323. - /**
  324. - Emitted when bytes are written to the Console
  325. -
  326. - \param bytes the number of bytes that were written
  327. -
  328. - \sa bytesAvailable()
  329. - */
  330. - void bytesWritten(int bytes);
  331. -
  332. - /**
  333. - Emitted when the console input is closed
  334. - */
  335. - void inputClosed();
  336. -
  337. - /**
  338. - Emitted when the console output is closed
  339. - */
  340. - void outputClosed();
  341. -
  342. -private:
  343. - Q_DISABLE_COPY(ConsoleReference)
  344. -
  345. - friend class ConsoleReferencePrivate;
  346. - ConsoleReferencePrivate *d;
  347. -
  348. - friend class Console;
  349. -};
  350. -
  351. -/**
  352. - \class ConsolePrompt qca_support.h QtCrypto
  353. -
  354. - Console prompt handler.
  355. -
  356. - This class provides a convenient way to get user input in a secure way,
  357. -as shown below:
  358. -\code
  359. -QCA::ConsolePrompt prompt;
  360. -prompt.getHidden("Passphrase");
  361. -prompt.waitForFinished();
  362. -QCA:SecureArray pass = prompt.result();
  363. -\endcode
  364. -
  365. - \note It is not necessary to use waitForFinished(), because you can
  366. - just connect the finished() signal to a suitable method, however
  367. - command line (console) applications often require waitForFinished().
  368. -
  369. - \ingroup UserAPI
  370. -*/
  371. -class QCA_EXPORT ConsolePrompt : public QObject
  372. -{
  373. - Q_OBJECT
  374. -public:
  375. - /**
  376. - Standard constructor
  377. -
  378. - \param parent the parent object for this object
  379. - */
  380. - ConsolePrompt(QObject *parent = nullptr);
  381. - ~ConsolePrompt() override;
  382. -
  383. - /**
  384. - Allow the user to enter data without it being echo'd to
  385. - the terminal. This is particularly useful for entry
  386. - of passwords, passphrases and PINs.
  387. -
  388. - \param promptStr the prompt to display to the user
  389. -
  390. - \sa result() for how to get the input back.
  391. - */
  392. - void getHidden(const QString &promptStr);
  393. -
  394. - /**
  395. - Obtain one character from the user
  396. -
  397. - \sa resultChar() for how to get the input back.
  398. - */
  399. - void getChar();
  400. -
  401. - /**
  402. - Block waiting for user input.
  403. -
  404. - You may wish to use the finished() signal to
  405. - avoid blocking.
  406. - */
  407. - void waitForFinished();
  408. -
  409. - /**
  410. - Obtain the result of the user input.
  411. -
  412. - This method is usually called to obtain data
  413. - from the user that was requested by the getHidden()
  414. - call.
  415. - */
  416. - SecureArray result() const;
  417. -
  418. - /**
  419. - Obtain the result of the user input.
  420. -
  421. - This method is usually called to obtain data
  422. - from the user that was requested by the getChar()
  423. - call.
  424. - */
  425. - QChar resultChar() const;
  426. -
  427. -Q_SIGNALS:
  428. - /**
  429. - Emitted when the user input activity has been
  430. - completed.
  431. -
  432. - This corresponds to the provision of a string
  433. - for getHidden() or a single character for getChar().
  434. -
  435. - \sa waitForFinished
  436. - */
  437. - void finished();
  438. -
  439. -private:
  440. - Q_DISABLE_COPY(ConsolePrompt)
  441. -
  442. - class Private;
  443. - friend class Private;
  444. - Private *d;
  445. -};
  446. class AbstractLogDevice;
  447. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
  448. index 7066839..85ae0d7 100644
  449. --- a/src/CMakeLists.txt
  450. +++ b/src/CMakeLists.txt
  451. @@ -44,7 +44,7 @@ SET( SOURCES
  452. qca_securelayer.cpp
  453. qca_securemessage.cpp
  454. support/qpipe.cpp
  455. - support/console.cpp
  456. + # support/console.cpp
  457. support/synchronizer.cpp
  458. support/dirwatch.cpp
  459. support/syncthread.cpp
  460. @@ -52,8 +52,8 @@ SET( SOURCES
  461. IF (WIN32)
  462. SET( SOURCES ${SOURCES} qca_systemstore_win.cpp )
  463. -elseif(APPLE)
  464. - set( SOURCES ${SOURCES} qca_systemstore_mac.cpp)
  465. + #elseif(APPLE)
  466. + # set( SOURCES ${SOURCES} qca_systemstore_mac.cpp)
  467. else()
  468. SET( SOURCES ${SOURCES} qca_systemstore_flatfile.cpp )
  469. endif()
  470. @@ -130,24 +130,24 @@ if(WIN32)
  471. TARGET_LINK_LIBRARIES(${QCA_LIB_NAME} crypt32 ws2_32)
  472. endif()
  473. -if(APPLE)
  474. - set(COREFOUNDATION_LIBRARY "-framework CoreFoundation")
  475. - set(COREFOUNDATION_LIBRARY_SECURITY "-framework Security")
  476. - TARGET_LINK_LIBRARIES(${QCA_LIB_NAME} ${COREFOUNDATION_LIBRARY} ${COREFOUNDATION_LIBRARY_SECURITY})
  477. -
  478. - if(NOT USE_RELATIVE_PATHS)
  479. - set_target_properties(${QCA_LIB_NAME} PROPERTIES
  480. - INSTALL_NAME_DIR "${QCA_LIBRARY_INSTALL_DIR}"
  481. - )
  482. - endif()
  483. -endif()
  484. -
  485. -if(NOT ANDROID)
  486. - set_target_properties(${QCA_LIB_NAME} PROPERTIES
  487. - VERSION ${QCA_LIB_MAJOR_VERSION}.${QCA_LIB_MINOR_VERSION}.${QCA_LIB_PATCH_VERSION}
  488. - SOVERSION ${QCA_LIB_MAJOR_VERSION}
  489. - )
  490. -endif()
  491. +#if(APPLE)
  492. +# set(COREFOUNDATION_LIBRARY "-framework CoreFoundation")
  493. +# set(COREFOUNDATION_LIBRARY_SECURITY "-framework Security")
  494. +# TARGET_LINK_LIBRARIES(${QCA_LIB_NAME} ${COREFOUNDATION_LIBRARY} ${COREFOUNDATION_LIBRARY_SECURITY})
  495. +#
  496. +# if(NOT USE_RELATIVE_PATHS)
  497. +# set_target_properties(${QCA_LIB_NAME} PROPERTIES
  498. +# INSTALL_NAME_DIR "${QCA_LIBRARY_INSTALL_DIR}"
  499. +# )
  500. +# endif()
  501. +#endif()
  502. +
  503. +#if(NOT ANDROID)
  504. +# set_target_properties(${QCA_LIB_NAME} PROPERTIES
  505. +# VERSION ${QCA_LIB_MAJOR_VERSION}.${QCA_LIB_MINOR_VERSION}.${QCA_LIB_PATCH_VERSION}
  506. +# SOVERSION ${QCA_LIB_MAJOR_VERSION}
  507. +# )
  508. +#endif()
  509. set_target_properties(${QCA_LIB_NAME} PROPERTIES
  510. DEFINE_SYMBOL QCA_MAKEDLL
  511. --
  512. 2.25.1