joincommandlinebuilder.h
1 //------------------------------------------------------------------------------
2 // joincommandlinebuilder.h
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2014 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #ifndef id3D55B51B_0F01_4FAB_8D44E1593B00E437
24 #define id3D55B51B_0F01_4FAB_8D44E1593B00E437
25 
26 #include "dptr.h"
27 #include "gui/missingwadsdialog.h"
28 #include "serverapi/serverptr.h"
29 #include <QObject>
30 
31 class CommandLineInfo;
32 class GameDemo;
33 class JoinError;
34 class Server;
36 class QAbstractButton;
37 class QUrl;
38 class QWidget;
39 
43 class JoinCommandLineBuilder : public QObject
44 {
45  Q_OBJECT
46 
47 public:
48  JoinCommandLineBuilder(ServerPtr server, GameDemo demo, QWidget *parentWidget);
49  ~JoinCommandLineBuilder() override;
50 
51  const CommandLineInfo &builtCommandLine() const;
52  static bool checkWadseekerValidity(QWidget *parent = nullptr);
53  bool isConfigurationError() const;
54  const QString &error() const;
59  void obtainJoinCommandLine();
60  ServerPtr server() const;
65  void setPasswords(const QString &connectPassword = QString(), const QString &inGamePassword = QString());
66 
67 signals:
68  void commandLineBuildFinished();
69 
70 private:
72 
73  bool buildServerConnectParams(ServerConnectParams &params);
74  bool checkServerStatus();
75  void failBuild();
76  void handleError(const JoinError &error);
77  MissingWadsDialog::MissingWadsProceed handleMissingWads(const JoinError &error);
78  QString mkDemoName();
79  bool tryToInstallGame();
80 
81 private slots:
82  void missingWadsClicked(QAbstractButton *);
83  void onWadseekerDone(int result);
84 };
85 
86 #endif