rcbuildtask.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #ifndef RCBUILDTASK_H
  2. #define RCBUILDTASK_H
  3. #include <QObject>
  4. #include <QStringList>
  5. #include <QTimer>
  6. namespace WccNameSpace{
  7. namespace Internal {
  8. // from WccApi
  9. class WccBuild;
  10. }
  11. }
  12. namespace WccApi = WccNameSpace::Internal;
  13. class GeneratorOutputView;
  14. class RcSession;
  15. /**
  16. * This class represents a remote build task.
  17. *
  18. * Usage: create an instance, include files for compilation,
  19. *
  20. */
  21. class RcBuildTask : public QObject
  22. {
  23. Q_OBJECT
  24. private:
  25. //
  26. // private members
  27. //
  28. GeneratorOutputView & m_generatorOutput;
  29. RcSession & m_session;
  30. QString m_projectName;
  31. QString m_projectDir;
  32. QStringList m_projectFiles;
  33. QString m_downloadDir;
  34. QString m_wccParams;
  35. QString m_savedPath;
  36. WccApi::WccBuild * m_build;
  37. QTimer m_timeout;
  38. public:
  39. /**
  40. * @param ui to put messages and error messages to.
  41. *
  42. * @param dir the path to the directory contaning the
  43. * sources to include in the remote build.
  44. */
  45. RcBuildTask(GeneratorOutputView & generatorOutput,
  46. RcSession & session,
  47. const QString & projectName,
  48. const QString & projectDir,
  49. QObject * parent = NULL);
  50. /**
  51. * Starts the process of building. Build steps are:
  52. *
  53. * (a) zip the source directory
  54. * (b) uploads it to the remote builder service
  55. * (c) downloads it when ready t dstDir
  56. *
  57. * @param wccParams is the string fragment to include
  58. * in the URL request, identifying the platform and qt version.
  59. * Example: "pSet[os]=s60_3_1&pSet[qt]=4_6_2".
  60. *
  61. * @param downloadDir destination dir to download the zip to.
  62. */
  63. void startBuilding(const QString & wccParams,
  64. const QString & downloadDir);
  65. signals:
  66. /**
  67. * For status updating: emitted when starting to zip the project
  68. * directory for sending to RC.
  69. */
  70. void zipping();
  71. /**
  72. * For status updating: emitted when starting to upload the zipped
  73. * project package.
  74. */
  75. void uploadingAndWaiting();
  76. /**
  77. * For status updating: emitted when starting to wait for the
  78. * uploaded package to be compiled.
  79. */
  80. void downloading();
  81. /**
  82. * Emitted when the build has been completed, either successfully
  83. * or due to an error.
  84. */
  85. void buildCompleted(bool success,
  86. QString downloadedFile);
  87. private slots:
  88. void zipProcessSucceedSlot(const QString &buildUrl, const QString &zipFileName);
  89. void zipProcessFailedSlot(const QString &eMsg);
  90. void sendZipOkSlot();
  91. void uploadedSlot(qint64 sent,
  92. qint64 total);
  93. void operationTimedOutSlot();
  94. void downloadFinishedSlot();
  95. private:
  96. /**
  97. * Traverses m_projectDir recursively and puts all files found
  98. * to m_projectFiles string list.
  99. */
  100. void traverseProjectDir();
  101. /**
  102. * Parses the log of compiling obtained from the remote build service.
  103. */
  104. void parseBuildLog(const QString & fullLog);
  105. };
  106. #endif // RCBUILDTASK_H