rcsession.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #ifndef RCSESSION_H
  2. #define RCSESSION_H
  3. #include <QObject>
  4. #include "settings.h"
  5. // from WccApi
  6. namespace WccNameSpace{
  7. namespace Internal {
  8. class WccNetworkAccessManager;
  9. }
  10. }
  11. namespace WccApi = WccNameSpace::Internal;
  12. // fwd decl of interface for user interaction
  13. class GeneratorOutputView;
  14. /**
  15. * RcSession represents a remote compiler session. Authentication
  16. * and further requests to the service are done through this instance.
  17. */
  18. class RcSession : public QObject
  19. {
  20. Q_OBJECT
  21. private:
  22. //
  23. // private members
  24. //
  25. GeneratorOutputView & m_outputView;
  26. WccApi::WccNetworkAccessManager * m_networkAccessManager;
  27. QString m_forumNokiaUserName;
  28. Settings::ProxyConfigKind m_proxyConfig;
  29. QString m_proxyUrl;
  30. quint16 m_proxyPort;
  31. QString m_proxyUserName;
  32. QString m_proxyPassword;
  33. QByteArray m_sessionIdCookie;
  34. int m_currentReqId;
  35. public:
  36. //
  37. // public operators
  38. //
  39. /**
  40. * Construct an RcSession loading the settings.
  41. * It will be in an non-connected,
  42. * unauthorized state.
  43. */
  44. RcSession(GeneratorOutputView & outputView,
  45. QObject * parent);
  46. ~RcSession();
  47. /**
  48. * @returns if this session is signed in to the remote compiler service.
  49. */
  50. bool isSignedOn() const;
  51. /**
  52. * Tries to sign in, if not signed in yet. May invoke methods on ui (ctor arg)
  53. * if necessary (such as proxy settings, authentication details and
  54. * password).
  55. */
  56. void signIn();
  57. /**
  58. * Signs off from service, loses state.
  59. */
  60. void signOut();
  61. /**
  62. * Loads the available targets from the service, and persists it to settings
  63. * (without parsing it, as it has been recevied).
  64. */
  65. void refreshRcProperties();
  66. /**
  67. * Creates a request URL, starting with the address of the service,
  68. * and ending with the request arguments (operation).
  69. *
  70. * @param operation the request arguments / operations to stick at the
  71. * end of the request URL created.
  72. */
  73. static QString makeRequestUrl(const QString & operation);
  74. /**
  75. * @returns the network access manager instance used.
  76. */
  77. WccApi::WccNetworkAccessManager * networkAccessManager();
  78. /**
  79. * @returns the next request id (each invocation increases).
  80. */
  81. int nextReqId();
  82. signals:
  83. /**
  84. * Emitted when signing process is done.
  85. *
  86. * @param success - whether signing in succeeded or failed.
  87. */
  88. void signInCompleted(bool success);
  89. /**
  90. * Emitted when RcProperties requesting has completed.
  91. *
  92. * @param success - whether request was successful
  93. *
  94. * @param hasRcPropertiesChanged - if the request was successful
  95. * and the persisted value of RcProperties have changed
  96. * this is also set to true.
  97. */
  98. void refreshRcPropertiesCompleted(bool success,
  99. bool hasRcPropertiesChanged);
  100. private slots:
  101. void ssoFormReplySlot();
  102. void ssoAuthReplySlot();
  103. void ssoTicketSendingFinishedSlot();
  104. void propertiesReplySlot();
  105. private:
  106. //
  107. // implementation details
  108. //
  109. void loadSettings();
  110. void setSessionIdCookie(const QByteArray & sessionIdCookie);
  111. };
  112. #endif // RCSESSION_H