summaryrefslogtreecommitdiffhomepage
path: root/migration/20170420_00-udp-naming.cpp
blob: 0361b7b904d7ae4cab87c6d20355f0bd84a55bf4 (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
/* Copyright (c) 2017, Stanislaw Halik <sthalik@misaki.pl>

 * Permission to use, copy, modify, and/or distribute this
 * software for any purpose with or without fee is hereby granted,
 * provided that the above copyright notice and this permission
 * notice appear in all copies.
 */

#include "migration.hpp"
#include "options/options.hpp"
#include "logic/main-settings.hpp"

using namespace migrations;
using namespace options;

static const char* const old_tracker_name = "UDP sender";
static const char* const old_proto_name = "UDP Tracker";

static const char* const new_tracker_name = "UDP over network";
static const char* const new_proto_name = "UDP over network";

struct rename_udp_stuff : migration
{
    bool should_run() const override
    {
        module_settings s;
        return s.protocol_dll == old_proto_name || s.tracker_dll == old_tracker_name;
    }

    void run() override
    {
        module_settings s;

        if (s.protocol_dll == old_proto_name)
            s.protocol_dll = new_proto_name;

        if (s.tracker_dll == old_tracker_name)
            s.tracker_dll = new_tracker_name;

        s.b->save();
    }

    QString unique_date() const override
    {
        return "20170420_00";
    }

    QString name() const override
    {
        return "rename confusing UDP tracker/proto names";
    }
};

OPENTRACK_MIGRATION(rename_udp_stuff);