summaryrefslogtreecommitdiff
path: root/src/nexusinterface.h
blob: dd9650b1148a89a109485a694d4418169e7bda75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
/*
Copyright (C) 2012 Sebastian Herbord. All rights reserved.

This file is part of Mod Organizer.

Mod Organizer is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Mod Organizer is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Mod Organizer.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef NEXUSINTERFACE_H
#define NEXUSINTERFACE_H

#include "apiuseraccount.h"
#include "plugincontainer.h"

#include <imodrepositorybridge.h>
#include <utility.h>
#include <versioninfo.h>

#include <QNetworkDiskCache>
#include <QNetworkReply>
#include <QQueue>
#include <QTimer>
#include <QVariant>

#include <list>
#include <set>

namespace MOBase
{
class IPluginGame;
}

class NexusInterface;
class NXMAccessManager;
class Settings;

/**
 * @brief convenience class to make nxm requests easier
 * usually, all objects that started a nxm request will be signaled if one finished.
 * Therefore, the objects need to store the id of the requests they started and then
 *filter the result. NexusBridge does this automatically. Users connect to the signals
 *of NexusBridge they intend to handle and only receive the signals the caused
 **/
class NexusBridge : public MOBase::IModRepositoryBridge
{

  Q_OBJECT

public:
  NexusBridge(PluginContainer* pluginContainer, const QString& subModule = "");

  /**
   * @brief request description for a mod
   *
   * @param modID id of the mod caller is interested in
   * @param userData user data to be returned with the result
   * @param url the url to request from
   **/
  virtual void requestDescription(QString gameName, int modID, QVariant userData);

  /**
   * @brief request a list of the files belonging to a mod
   *
   * @param modID id of the mod caller is interested in
   * @param userData user data to be returned with the result
   **/
  virtual void requestFiles(QString gameName, int modID, QVariant userData);

  /**
   * @brief request info about a single file of a mod
   *
   * @param modID id of the mod caller is interested in
   * @param fileID id of the file the caller is interested in
   * @param userData user data to be returned with the result
   **/
  virtual void requestFileInfo(QString gameName, int modID, int fileID,
                               QVariant userData);

  /**
   * @brief request the download url of a file
   *
   * @param modID id of the mod caller is interested in
   * @param fileID id of the file the caller is interested in
   * @param userData user data to be returned with the result
   **/
  virtual void requestDownloadURL(QString gameName, int modID, int fileID,
                                  QVariant userData);

  /**
   * @brief requestToggleEndorsement
   * @param modID id of the mod caller is interested in
   * @param userData user data to be returned with the result
   */
  virtual void requestToggleEndorsement(QString gameName, int modID, QString modVersion,
                                        bool endorse, QVariant userData);

  /**
   * @brief requestToggleTracking
   * @param modID id of the mod caller is interested in
   * @param userData user data to be returned with the result
   */
  virtual void requestToggleTracking(QString gameName, int modID, bool track,
                                     QVariant userData);

  /**
   * @brief requestGameInfo
   * @param userData user data to be returned with the result
   */
  virtual void requestGameInfo(QString gameName, QVariant userData);

public slots:

  void nxmDescriptionAvailable(QString gameName, int modID, QVariant userData,
                               QVariant resultData, int requestID);
  void nxmFilesAvailable(QString gameName, int modID, QVariant userData,
                         QVariant resultData, int requestID);
  void nxmFileInfoAvailable(QString gameName, int modID, int fileID, QVariant userData,
                            QVariant resultData, int requestID);
  void nxmDownloadURLsAvailable(QString gameName, int modID, int fileID,
                                QVariant userData, QVariant resultData, int requestID);
  void nxmEndorsementsAvailable(QVariant userData, QVariant resultData, int requestID);
  void nxmEndorsementToggled(QString gameName, int modID, QVariant userData,
                             QVariant resultData, int requestID);
  void nxmTrackedModsAvailable(QVariant userData, QVariant resultData, int requestID);
  void nxmTrackingToggled(QString gameName, int modID, QVariant userData, bool tracked,
                          int requestID);
  void nxmGameInfoAvailable(QString gameName, QVariant userData, QVariant resultData,
                            int requestID);
  void nxmRequestFailed(QString gameName, int modID, int fileID, QVariant userData,
                        int requestID, int errorCode, const QString& errorMessage);

private:
  NexusInterface* m_Interface;
  QString m_SubModule;
  std::set<int> m_RequestIDs;
};

/**
 * @brief Makes asynchronous requests to the nexus API
 *
 * This class can be used to make asynchronous requests to the Nexus API.
 * Currently, responses are sent to all receivers that have sent a request of the
 *relevant type, so the recipient has to filter the response by the id returned when
 *making the request
 **/
class NexusInterface : public QObject
{
  Q_OBJECT

public:
  enum UpdatePeriod
  {
    NONE,
    DAY,
    WEEK,
    MONTH
  };

  // Nexus file category IDs (MAIN, OLD etc), not to be confused with mod categories
  // (Armors, Texture etc).
  enum FileStatus
  {
    MAIN          = 1,
    UPDATE        = 2,
    OPTIONAL_FILE = 3,  // actual string version is "OPTIONAL", but that is already
                        // defined as a macro in minwindef.h
    OLD_VERSION     = 4,
    MISCELLANEOUS   = 5,
    REMOVED         = 6,
    ARCHIVED        = 7,
    ARCHIVED_HIDDEN = 1000  // Archived files can be hidden by authors so if they aren't
                            // listed we can assume they were hidden.
  };

  /**
   * @brief Whether a Nexus file category represents a file that is still
   *   listed and considered current on the mod page.
   *
   * Inactive (false) refers to files that have been marked as obsolete or have been
   * removed.
   */
  static bool isActiveFileStatus(int status)
  {
    switch (status) {
    case FileStatus::MAIN:
    case FileStatus::UPDATE:
    case FileStatus::OPTIONAL_FILE:
    case FileStatus::MISCELLANEOUS:
      return true;
    case FileStatus::OLD_VERSION:
    case FileStatus::REMOVED:
    case FileStatus::ARCHIVED:
    case FileStatus::ARCHIVED_HIDDEN:
      return false;
    default:
      return false;
    }
  }

public:
  static APILimits defaultAPILimits();
  static APILimits parseLimits(const QNetworkReply* reply);
  static APILimits parseLimits(const QList<QNetworkReply::RawHeaderPair>& headers);

  NexusInterface(Settings* s);
  ~NexusInterface();

  static NexusInterface& instance();

  /**
   * @return the access manager object used to connect to nexus
   **/
  NXMAccessManager* getAccessManager();

  /**
   * @brief cleanup this interface. this is destructive, afterwards it can't be used
   * again
   */
  void cleanup();

  /**
   * @brief clear webcache and cookies associated with this access manager
   */
  void clearCache();

  /**
   * @brief request description for a mod
   *
   * @param gameName the game short name to support multiple game sources
   * @param modID id of the mod caller is interested in (assumed to be for the current
   *game)
   * @param receiver the object to receive the result asynchronously via a signal
   *(nxmDescriptionAvailable)
   * @param userData user data to be returned with the result
   * @return int an id to identify the request
   **/
  int requestDescription(QString gameName, int modID, QObject* receiver,
                         QVariant userData, const QString& subModule)
  {
    return requestDescription(gameName, modID, receiver, userData, subModule,
                              getGame(gameName));
  }

  /**
   * @brief request description for a mod
   *
   * @param gameName the game short name to support multiple game sources
   * @param modID id of the mod caller is interested in
   * @param receiver the object to receive the result asynchronously via a signal
   *(nxmDescriptionAvailable)
   * @param userData user data to be returned with the result
   * @param game Game with which the mod is associated
   * @return int an id to identify the request
   **/
  int requestDescription(QString gameName, int modID, QObject* receiver,
                         QVariant userData, const QString& subModule,
                         MOBase::IPluginGame const* game);

  /**
   * @brief request description for a mod
   *
   * @param gameName the game short name to support multiple game sources
   * @param modID id of the mod caller is interested in (assumed to be for the current
   *game)
   * @param receiver the object to receive the result asynchronously via a signal
   *(nxmModInfoAvailable)
   * @param userData user data to be returned with the result
   * @return int an id to identify the request
   **/
  int requestModInfo(QString gameName, int modID, QObject* receiver, QVariant userData,
                     const QString& subModule)
  {
    return requestModInfo(gameName, modID, receiver, userData, subModule,
                          getGame(gameName));
  }

  /**
   * @brief request mod info
   *
   * @param gameName the game short name to support multiple game sources
   * @param modID id of the mod caller is interested in
   * @param receiver the object to receive the result asynchronously via a signal
   *(nxmModInfoAvailable)
   * @param userData user data to be returned with the result
   * @param game Game with which the mod is associated
   * @return int an id to identify the request
   **/
  int requestModInfo(QString gameName, int modID, QObject* receiver, QVariant userData,
                     const QString& subModule, MOBase::IPluginGame const* game);

  int requestUpdateInfo(QString gameName, NexusInterface::UpdatePeriod period,
                        QObject* receiver, QVariant userData, const QString& subModule)
  {
    return requestUpdateInfo(gameName, period, receiver, userData, subModule,
                             getGame(gameName));
  }

  int requestUpdateInfo(QString gameName, NexusInterface::UpdatePeriod period,
                        QObject* receiver, QVariant userData, const QString& subModule,
                        const MOBase::IPluginGame* game);

  /**
   * @brief request nexus descriptions for multiple mods at once
   * @param modID id of the mod the caller is interested in
   * @param receiver the object to receive the result asynchronously via a signal
   * (nxmDescriptionAvailable)
   * @param userData user data to be returned with the result
   * @param gameName the game with which the mods are associated
   * @return int an id to identify the request
   */
  int requestUpdates(const int& modID, QObject* receiver, QVariant userData,
                     QString gameName, const QString& subModule);

  /**
   * @brief request a list of the files belonging to a mod
   *
   * @param gameName the game short name to support multiple game sources
   * @param modID id of the mod caller is interested in (assumed to be for the current
   *game)
   * @param receiver the object to receive the result asynchronously via a signal
   *(nxmFilesAvailable)
   * @param userData user data to be returned with the result
   * @return int an id to identify the request
   **/
  int requestFiles(QString gameName, int modID, QObject* receiver, QVariant userData,
                   const QString& subModule)
  {
    return requestFiles(gameName, modID, receiver, userData, subModule,
                        getGame(gameName));
  }

  /**
   * @brief request a list of the files belonging to a mod
   *
   * @param gameName the game short name to support multiple game sources
   * @param modID id of the mod caller is interested in
   * @param receiver the object to receive the result asynchronously via a signal
   *(nxmFilesAvailable)
   * @param userData user data to be returned with the result
   * @param game the game with which the mods are associated
   * @return int an id to identify the request
   **/
  int requestFiles(QString gameName, int modID, QObject* receiver, QVariant userData,
                   const QString& subModule, MOBase::IPluginGame const* game);

  /**
   * @brief request info about a single file of a mod
   *
   * @param gameName name of the game short name to request the download from
   * @param modID id of the mod caller is interested in (assumed to be for the current
   *game)
   * @param fileID id of the file the caller is interested in
   * @param receiver the object to receive the result asynchronously via a signal
   *(nxmFilesAvailable)
   * @param userData user data to be returned with the result
   * @return int an id to identify the request
   **/
  int requestFileInfo(QString gameName, int modID, int fileID, QObject* receiver,
                      QVariant userData, const QString& subModule);

  /**
   * @brief request the download url of a file
   *
   * @param gameName the game short name to support multiple game sources
   * @param modID id of the mod caller is interested in (assumed to be for the current
   *game)
   * @param fileID id of the file the caller is interested in
   * @param receiver the object to receive the result asynchronously via a signal
   *(nxmFilesAvailable)
   * @param userData user data to be returned with the result
   * @return int an id to identify the request
   **/
  int requestDownloadURL(QString gameName, int modID, int fileID, QObject* receiver,
                         QVariant userData, const QString& subModule)
  {
    return requestDownloadURL(gameName, modID, fileID, receiver, userData, subModule,
                              getGame(gameName));
  }

  /**
   * @brief request the download url of a file
   *
   * @param gameName the game short name to support multiple game sources
   * @param modID id of the mod caller is interested in
   * @param fileID id of the file the caller is interested in
   * @param receiver the object to receive the result asynchronously via a signal
   *(nxmFilesAvailable)
   * @param userData user data to be returned with the result
   * @param game the game with which the mods are associated
   * @return int an id to identify the request
   **/
  int requestDownloadURL(QString gameName, int modID, int fileID, QObject* receiver,
                         QVariant userData, const QString& subModule,
                         MOBase::IPluginGame const* game);

  int requestEndorsementInfo(QObject* receiver, QVariant userData,
                             const QString& subModule);

  /**
   * @param gameName the game short name to support multiple game sources
   * @brief toggle endorsement state of the mod
   * @param modID id of the mod (assumed to be for the current game)
   * @param endorse true if the mod should be endorsed, false for un-endorse
   * @param receiver the object to receive the result asynchronously via a signal
   * (nxmFilesAvailable)
   * @param userData user data to be returned with the result
   * @return int an id to identify the request
   */
  int requestToggleEndorsement(QString gameName, int modID, QString modVersion,
                               bool endorse, QObject* receiver, QVariant userData,
                               const QString& subModule)
  {
    return requestToggleEndorsement(gameName, modID, modVersion, endorse, receiver,
                                    userData, subModule, getGame(gameName));
  }

  /**
   * @param gameName the game short name to support multiple game sources
   * @brief toggle endorsement state of the mod
   * @param modID id of the mod
   * @param endorse true if the mod should be endorsed, false for un-endorse
   * @param receiver the object to receive the result asynchronously via a signal
   * (nxmFilesAvailable)
   * @param userData user data to be returned with the result
   * @param game the game with which the mods are associated
   * @return int an id to identify the request
   */
  int requestToggleEndorsement(QString gameName, int modID, QString modVersion,
                               bool endorse, QObject* receiver, QVariant userData,
                               const QString& subModule,
                               MOBase::IPluginGame const* game);

  int requestTrackingInfo(QObject* receiver, QVariant userData,
                          const QString& subModule);

  /**
   * @param gameName the game short name to support multiple game sources
   * @brief toggle tracking state of the mod
   * @param modID id of the mod
   * @param track true if the mod should be tracked, false for not tracked
   * @param receiver the object to receive the result asynchronously via a signal
   * (nxmFilesAvailable)
   * @param userData user data to be returned with the result
   * @param game the game with which the mods are associated
   * @return int an id to identify the request
   */
  int requestToggleTracking(QString gameName, int modID, bool track, QObject* receiver,
                            QVariant userData, const QString& subModule)
  {
    return requestToggleTracking(gameName, modID, track, receiver, userData, subModule,
                                 getGame(gameName));
  }

  /**
   * @param gameName the game short name to support multiple game sources
   * @brief toggle tracking state of the mod
   * @param modID id of the mod
   * @param track true if the mod should be tracked, false for not tracked
   * @param receiver the object to receive the result asynchronously via a signal
   * (nxmFilesAvailable)
   * @param userData user data to be returned with the result
   * @param game the game with which the mods are associated
   * @return int an id to identify the request
   */
  int requestToggleTracking(QString gameName, int modID, bool track, QObject* receiver,
                            QVariant userData, const QString& subModule,
                            MOBase::IPluginGame const* game);

  /**
   * @param gameName the game short name to support multiple game sources
   * @brief toggle tracking state of the mod
   * @param modID id of the mod
   * @param track true if the mod should be tracked, false for not tracked
   * @param receiver the object to receive the result asynchronously via a signal
   * (nxmFilesAvailable)
   * @param userData user data to be returned with the result
   * @param game the game with which the mods are associated
   * @return int an id to identify the request
   */
  int requestGameInfo(QString gameName, QObject* receiver, QVariant userData,
                      const QString& subModule)
  {
    return requestGameInfo(gameName, receiver, userData, subModule, getGame(gameName));
  }

  /**
   * @param gameName the game short name to support multiple game sources
   * @brief toggle tracking state of the mod
   * @param modID id of the mod
   * @param track true if the mod should be tracked, false for not tracked
   * @param receiver the object to receive the result asynchronously via a signal
   * (nxmFilesAvailable)
   * @param userData user data to be returned with the result
   * @param game the game with which the mods are associated
   * @return int an id to identify the request
   */
  int requestGameInfo(QString gameName, QObject* receiver, QVariant userData,
                      const QString& subModule, MOBase::IPluginGame const* game);

  /**
   *
   */
  int requestInfoFromMd5(QString gameName, QByteArray& hash, QObject* receiver,
                         QVariant userData, const QString& subModule)
  {
    return requestInfoFromMd5(gameName, hash, receiver, userData, subModule,
                              getGame(gameName));
  }

  /**
   *
   */
  int requestInfoFromMd5(QString gameName, QByteArray& hash, QObject* receiver,
                         QVariant userData, const QString& subModule,
                         MOBase::IPluginGame const* game);

  /**
   * @param directory the directory to store cache files
   **/
  void setCacheDirectory(const QString& directory);

  /**
   * @brief called when the log-in completes. This was, requests waiting for the log-in
   * can be run
   */
  void loginCompleted();

  std::vector<std::pair<QString, QString>>
  getGameChoices(const MOBase::IPluginGame* game);

  APIUserAccount getAPIUserAccount() const;
  APIStats getAPIStats() const;

public:
  /**
   * @brief guess the mod id from a filename as delivered by Nexus
   * @param fileName name of the file
   * @return the guessed mod id
   * @note this currently doesn't fit well with the remaining interface but this is the
   * best place for the function
   */
  static void interpretNexusFileName(const QString& fileName, QString& modName,
                                     int& modID, bool query);

  /**
   * @brief get the currently managed game
   */
  MOBase::IPluginGame const* managedGame() const;

  /**
   * @brief see if the passed URL is related to the current game
   *
   * Arguably, this should optionally take a gameplugin pointer
   */
  bool isURLGameRelated(QUrl const& url) const;

  /**
   * @brief Get the nexus page for the current game
   *
   * Arguably, this should optionally take a gameplugin pointer
   */
  QString getGameURL(QString gameName) const;

  /**
   * @brief Get the URL for the mod web page
   * @param modID
   */
  QString getModURL(int modID, QString gameName) const;

  /**
   * @brief Checks if the specified URL might correspond to a nexus mod
   * @param modID
   * @param url
   * @return
   */
  bool isModURL(int modID, QString const& url) const;

  void setPluginContainer(PluginContainer* pluginContainer);

signals:

  void requestNXMDownload(const QString& url);

  void needLogin();

  void nxmDescriptionAvailable(QString gameName, int modID, QVariant userData,
                               QVariant resultData, int requestID);
  void nxmModInfoAvailable(QString gameName, int modID, QVariant userData,
                           QVariant resultData, int requestID);
  void nxmUpdateInfoAvailable(QString gameName, QVariant userData, QVariant resultData,
                              int requestID);
  void nxmUpdatesAvailable(QString gameName, int modID, QVariant userData,
                           QVariant resultData, int requestID);
  void nxmFilesAvailable(QString gameName, int modID, QVariant userData,
                         QVariant resultData, int requestID);
  void nxmFileInfoAvailable(QString gameName, int modID, int fileID, QVariant userData,
                            QVariant resultData, int requestID);
  void nxmFileInfoFromMd5Available(QString gameName, QVariant userData,
                                   QVariant resultData, int requestID);
  void nxmDownloadURLsAvailable(QString gameName, int modID, int fileID,
                                QVariant userData, QVariant resultData, int requestID);
  void nxmEndorsementsAvailable(QVariant userData, QVariant resultData, int requestID);
  void nxmEndorsementToggled(QString gameName, int modID, QVariant userData,
                             QVariant resultData, int requestID);
  void nxmTrackedModsAvailable(QVariant userData, QVariant resultData, int requestID);
  void nxmTrackingToggled(QString gameName, int modID, QVariant userData, bool tracked,
                          int requestID);
  void nxmGameInfoAvailable(QString gameName, QVariant userData, QVariant resultData,
                            int requestID);
  void nxmRequestFailed(QString gameName, int modID, int fileID, QVariant userData,
                        int requestID, int errorCode, const QString& errorString);
  void requestsChanged(const APIStats& stats, const APIUserAccount& user);

public slots:

  void setUserAccount(const APIUserAccount& user);

private slots:

  void requestFinished();
  void requestError(QNetworkReply::NetworkError error);
  void requestTimeout();

  void downloadRequestedNXM(const QString& url);

  void fakeFiles();

private:
  struct NXMRequestInfo
  {
    int m_ModID;
    QString m_ModVersion;
    std::vector<int> m_ModIDList;
    int m_FileID;
    QNetworkReply* m_Reply;
    enum Type
    {
      TYPE_DESCRIPTION,
      TYPE_MODINFO,
      TYPE_FILES,
      TYPE_FILEINFO,
      TYPE_DOWNLOADURL,
      TYPE_ENDORSEMENTS,
      TYPE_TOGGLEENDORSEMENT,
      TYPE_GETUPDATES,
      TYPE_CHECKUPDATES,
      TYPE_TOGGLETRACKING,
      TYPE_TRACKEDMODS,
      TYPE_FILEINFO_MD5,
      TYPE_GAMEINFO,
    } m_Type;
    UpdatePeriod m_UpdatePeriod;
    QVariant m_UserData;
    QTimer* m_Timeout;
    QString m_URL;
    QString m_SubModule;
    QString m_GameName;
    int m_NexusGameID;
    bool m_Reroute;
    int m_ID;
    int m_Endorse;
    int m_Track;
    QByteArray m_Hash;
    QMap<QNetworkReply::NetworkError, QList<int>> m_AllowedErrors;
    bool m_IgnoreGenericErrorHandler;

    NXMRequestInfo(int modID, Type type, QVariant userData, const QString& subModule,
                   MOBase::IPluginGame const* game);
    NXMRequestInfo(int modID, QString modVersion, Type type, QVariant userData,
                   const QString& subModule, MOBase::IPluginGame const* game);
    NXMRequestInfo(int modID, int fileID, Type type, QVariant userData,
                   const QString& subModule, MOBase::IPluginGame const* game);
    NXMRequestInfo(Type type, QVariant userData, const QString& subModule,
                   MOBase::IPluginGame const* game);
    NXMRequestInfo(Type type, QVariant userData, const QString& subModule);
    NXMRequestInfo(UpdatePeriod period, Type type, QVariant userData,
                   const QString& subModule, MOBase::IPluginGame const* game);
    NXMRequestInfo(QByteArray& hash, Type type, QVariant userData,
                   const QString& subModule, MOBase::IPluginGame const* game);

  private:
    static QAtomicInt s_NextID;
  };

  static const int MAX_ACTIVE_DOWNLOADS = 6;

private:
  void nextRequest();
  void requestFinished(std::list<NXMRequestInfo>::iterator iter);
  MOBase::IPluginGame* getGame(QString gameName) const;
  QString getOldModsURL(QString gameName) const;

private:
  QNetworkDiskCache* m_DiskCache;
  NXMAccessManager* m_AccessManager;
  std::list<NXMRequestInfo> m_ActiveRequest;
  QQueue<NXMRequestInfo> m_RequestQueue;
  PluginContainer* m_PluginContainer;
  APIUserAccount m_User;
};

#endif  // NEXUSINTERFACE_H