summaryrefslogtreecommitdiffhomepage
path: root/migration/20160906_02-modules.cpp
blob: ea635f67fc1fbfc6f8e49d01d4fd48b9b1aa06d7 (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
#include "migration.hpp"
#include "options/options.hpp"

#include <QString>
#include <QVariant>

using namespace options;
using namespace migrations;

struct split_modules_rc11 : migration
{
    split_modules_rc11() = default;

    static const char* names[3];

    QString unique_date() const override
    {
        return "20160909_02";
    }

    QString name() const override
    {
        return "split modules to their own section";
    }

    bool should_run() const override
    {
        bundle new_bundle = make_bundle("modules");
        bundle old_bundle = make_bundle("opentrack-ui");

        for (const char* name : names)
            if (new_bundle->contains(name))
                return false;

        for (const char* name : names)
            if (old_bundle->contains(name))
                return true;

        return false;
    }

    void run() override
    {
        bundle new_bundle = make_bundle("modules");
        bundle old_bundle = make_bundle("opentrack-ui");

        for (const char* name : names)
            new_bundle->store_kv(name, QVariant(old_bundle->get<QString>(name)));

        new_bundle->save();
    }
};

const char* split_modules_rc11::names[3] =
{
    "tracker-dll",
    "protocol-dll",
    "filter-dll",
};

OPENTRACK_MIGRATION(split_modules_rc11);