mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 17:43:23 -08:00
[Client] DeckSyncProfile + sidecar + DeckDiff with tests
This commit is contained in:
parent
11fdfb4610
commit
1e97ab086b
12 changed files with 740 additions and 0 deletions
42
cockatrice/src/interface/deck_sync/deck_sync_profile.h
Normal file
42
cockatrice/src/interface/deck_sync/deck_sync_profile.h
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/**
|
||||
* @file deck_sync_profile.h
|
||||
* @brief Identity of one sync target (server + user) for deck collection sync.
|
||||
*/
|
||||
|
||||
#ifndef DECK_SYNC_PROFILE_H
|
||||
#define DECK_SYNC_PROFILE_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
/**
|
||||
* @struct DeckSyncProfile
|
||||
* @brief Identifies which server and login a sync sidecar belongs to.
|
||||
*
|
||||
* A local deck folder can sync against several servers. Every server login
|
||||
* gets its own profile, and every profile gets its own sidecar file, so
|
||||
* switching servers never mixes up remote deck ids.
|
||||
*/
|
||||
struct DeckSyncProfile
|
||||
{
|
||||
QString host; ///< Server hostname as entered by the user.
|
||||
int port = 0; ///< Server port.
|
||||
QString username; ///< Login name on that server.
|
||||
|
||||
DeckSyncProfile() = default;
|
||||
DeckSyncProfile(const QString &_host, int _port, const QString &_username);
|
||||
|
||||
/** @brief False when any of host, port or username is missing. */
|
||||
[[nodiscard]] bool isValid() const;
|
||||
/**
|
||||
* @brief Stable file-system-safe key for this profile.
|
||||
*
|
||||
* SHA1 hex over the NUL-separated lowercased "host", port and "username"
|
||||
* triple, so the same server reached with different hostname
|
||||
* capitalisation maps to one file, while IPv6 hosts and usernames
|
||||
* containing ':' can never collide two profiles. Empty for invalid
|
||||
* profiles, so no two half-configured profiles share a file.
|
||||
*/
|
||||
[[nodiscard]] QString key() const;
|
||||
};
|
||||
|
||||
#endif // DECK_SYNC_PROFILE_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue