Browse Source

Avoid data duplication

adaptive-webui-19844
Chocobo1 4 years ago
parent
commit
e21f46d824
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 72
      src/base/http/types.h
  2. 92
      src/webui/api/serialize/serialize_torrent.h

72
src/base/http/types.h

@ -35,43 +35,43 @@ @@ -35,43 +35,43 @@
namespace Http
{
const char METHOD_GET[] = "GET";
const char METHOD_POST[] = "POST";
const char HEADER_CACHE_CONTROL[] = "cache-control";
const char HEADER_CONNECTION[] = "connection";
const char HEADER_CONTENT_DISPOSITION[] = "content-disposition";
const char HEADER_CONTENT_ENCODING[] = "content-encoding";
const char HEADER_CONTENT_LENGTH[] = "content-length";
const char HEADER_CONTENT_SECURITY_POLICY[] = "content-security-policy";
const char HEADER_CONTENT_TYPE[] = "content-type";
const char HEADER_DATE[] = "date";
const char HEADER_HOST[] = "host";
const char HEADER_ORIGIN[] = "origin";
const char HEADER_REFERER[] = "referer";
const char HEADER_REFERRER_POLICY[] = "referrer-policy";
const char HEADER_SET_COOKIE[] = "set-cookie";
const char HEADER_X_CONTENT_TYPE_OPTIONS[] = "x-content-type-options";
const char HEADER_X_FORWARDED_HOST[] = "x-forwarded-host";
const char HEADER_X_FRAME_OPTIONS[] = "x-frame-options";
const char HEADER_X_XSS_PROTECTION[] = "x-xss-protection";
const char HEADER_REQUEST_METHOD_GET[] = "GET";
const char HEADER_REQUEST_METHOD_HEAD[] = "HEAD";
const char HEADER_REQUEST_METHOD_POST[] = "POST";
const char CONTENT_TYPE_HTML[] = "text/html";
const char CONTENT_TYPE_CSS[] = "text/css";
const char CONTENT_TYPE_TXT[] = "text/plain; charset=UTF-8";
const char CONTENT_TYPE_JS[] = "application/javascript";
const char CONTENT_TYPE_JSON[] = "application/json";
const char CONTENT_TYPE_GIF[] = "image/gif";
const char CONTENT_TYPE_PNG[] = "image/png";
const char CONTENT_TYPE_FORM_ENCODED[] = "application/x-www-form-urlencoded";
const char CONTENT_TYPE_FORM_DATA[] = "multipart/form-data";
inline const char METHOD_GET[] = "GET";
inline const char METHOD_POST[] = "POST";
inline const char HEADER_CACHE_CONTROL[] = "cache-control";
inline const char HEADER_CONNECTION[] = "connection";
inline const char HEADER_CONTENT_DISPOSITION[] = "content-disposition";
inline const char HEADER_CONTENT_ENCODING[] = "content-encoding";
inline const char HEADER_CONTENT_LENGTH[] = "content-length";
inline const char HEADER_CONTENT_SECURITY_POLICY[] = "content-security-policy";
inline const char HEADER_CONTENT_TYPE[] = "content-type";
inline const char HEADER_DATE[] = "date";
inline const char HEADER_HOST[] = "host";
inline const char HEADER_ORIGIN[] = "origin";
inline const char HEADER_REFERER[] = "referer";
inline const char HEADER_REFERRER_POLICY[] = "referrer-policy";
inline const char HEADER_SET_COOKIE[] = "set-cookie";
inline const char HEADER_X_CONTENT_TYPE_OPTIONS[] = "x-content-type-options";
inline const char HEADER_X_FORWARDED_HOST[] = "x-forwarded-host";
inline const char HEADER_X_FRAME_OPTIONS[] = "x-frame-options";
inline const char HEADER_X_XSS_PROTECTION[] = "x-xss-protection";
inline const char HEADER_REQUEST_METHOD_GET[] = "GET";
inline const char HEADER_REQUEST_METHOD_HEAD[] = "HEAD";
inline const char HEADER_REQUEST_METHOD_POST[] = "POST";
inline const char CONTENT_TYPE_HTML[] = "text/html";
inline const char CONTENT_TYPE_CSS[] = "text/css";
inline const char CONTENT_TYPE_TXT[] = "text/plain; charset=UTF-8";
inline const char CONTENT_TYPE_JS[] = "application/javascript";
inline const char CONTENT_TYPE_JSON[] = "application/json";
inline const char CONTENT_TYPE_GIF[] = "image/gif";
inline const char CONTENT_TYPE_PNG[] = "image/png";
inline const char CONTENT_TYPE_FORM_ENCODED[] = "application/x-www-form-urlencoded";
inline const char CONTENT_TYPE_FORM_DATA[] = "multipart/form-data";
// portability: "\r\n" doesn't guarantee mapping to the correct symbol
const char CRLF[] = {0x0D, 0x0A, '\0'};
inline const char CRLF[] = {0x0D, 0x0A, '\0'};
struct Environment
{
@ -120,7 +120,7 @@ namespace Http @@ -120,7 +120,7 @@ namespace Http
HeaderMap headers;
QByteArray content;
Response(uint code = 200, const QString &text = "OK")
Response(uint code = 200, const QString &text = QLatin1String("OK"))
: status {code, text}
{
}

92
src/webui/api/serialize/serialize_torrent.h

@ -36,51 +36,51 @@ namespace BitTorrent @@ -36,51 +36,51 @@ namespace BitTorrent
}
// Torrent keys
const char KEY_TORRENT_ID[] = "hash";
const char KEY_TORRENT_NAME[] = "name";
const char KEY_TORRENT_MAGNET_URI[] = "magnet_uri";
const char KEY_TORRENT_SIZE[] = "size";
const char KEY_TORRENT_PROGRESS[] = "progress";
const char KEY_TORRENT_DLSPEED[] = "dlspeed";
const char KEY_TORRENT_UPSPEED[] = "upspeed";
const char KEY_TORRENT_QUEUE_POSITION[] = "priority";
const char KEY_TORRENT_SEEDS[] = "num_seeds";
const char KEY_TORRENT_NUM_COMPLETE[] = "num_complete";
const char KEY_TORRENT_LEECHS[] = "num_leechs";
const char KEY_TORRENT_NUM_INCOMPLETE[] = "num_incomplete";
const char KEY_TORRENT_RATIO[] = "ratio";
const char KEY_TORRENT_ETA[] = "eta";
const char KEY_TORRENT_STATE[] = "state";
const char KEY_TORRENT_SEQUENTIAL_DOWNLOAD[] = "seq_dl";
const char KEY_TORRENT_FIRST_LAST_PIECE_PRIO[] = "f_l_piece_prio";
const char KEY_TORRENT_CATEGORY[] = "category";
const char KEY_TORRENT_TAGS[] = "tags";
const char KEY_TORRENT_SUPER_SEEDING[] = "super_seeding";
const char KEY_TORRENT_FORCE_START[] = "force_start";
const char KEY_TORRENT_SAVE_PATH[] = "save_path";
const char KEY_TORRENT_CONTENT_PATH[] = "content_path";
const char KEY_TORRENT_ADDED_ON[] = "added_on";
const char KEY_TORRENT_COMPLETION_ON[] = "completion_on";
const char KEY_TORRENT_TRACKER[] = "tracker";
const char KEY_TORRENT_TRACKERS_COUNT[] = "trackers_count";
const char KEY_TORRENT_DL_LIMIT[] = "dl_limit";
const char KEY_TORRENT_UP_LIMIT[] = "up_limit";
const char KEY_TORRENT_AMOUNT_DOWNLOADED[] = "downloaded";
const char KEY_TORRENT_AMOUNT_UPLOADED[] = "uploaded";
const char KEY_TORRENT_AMOUNT_DOWNLOADED_SESSION[] = "downloaded_session";
const char KEY_TORRENT_AMOUNT_UPLOADED_SESSION[] = "uploaded_session";
const char KEY_TORRENT_AMOUNT_LEFT[] = "amount_left";
const char KEY_TORRENT_AMOUNT_COMPLETED[] = "completed";
const char KEY_TORRENT_MAX_RATIO[] = "max_ratio";
const char KEY_TORRENT_MAX_SEEDING_TIME[] = "max_seeding_time";
const char KEY_TORRENT_RATIO_LIMIT[] = "ratio_limit";
const char KEY_TORRENT_SEEDING_TIME_LIMIT[] = "seeding_time_limit";
const char KEY_TORRENT_LAST_SEEN_COMPLETE_TIME[] = "seen_complete";
const char KEY_TORRENT_LAST_ACTIVITY_TIME[] = "last_activity";
const char KEY_TORRENT_TOTAL_SIZE[] = "total_size";
const char KEY_TORRENT_AUTO_TORRENT_MANAGEMENT[] = "auto_tmm";
const char KEY_TORRENT_TIME_ACTIVE[] = "time_active";
const char KEY_TORRENT_SEEDING_TIME[] = "seeding_time";
const char KEY_TORRENT_AVAILABILITY[] = "availability";
inline const char KEY_TORRENT_ID[] = "hash";
inline const char KEY_TORRENT_NAME[] = "name";
inline const char KEY_TORRENT_MAGNET_URI[] = "magnet_uri";
inline const char KEY_TORRENT_SIZE[] = "size";
inline const char KEY_TORRENT_PROGRESS[] = "progress";
inline const char KEY_TORRENT_DLSPEED[] = "dlspeed";
inline const char KEY_TORRENT_UPSPEED[] = "upspeed";
inline const char KEY_TORRENT_QUEUE_POSITION[] = "priority";
inline const char KEY_TORRENT_SEEDS[] = "num_seeds";
inline const char KEY_TORRENT_NUM_COMPLETE[] = "num_complete";
inline const char KEY_TORRENT_LEECHS[] = "num_leechs";
inline const char KEY_TORRENT_NUM_INCOMPLETE[] = "num_incomplete";
inline const char KEY_TORRENT_RATIO[] = "ratio";
inline const char KEY_TORRENT_ETA[] = "eta";
inline const char KEY_TORRENT_STATE[] = "state";
inline const char KEY_TORRENT_SEQUENTIAL_DOWNLOAD[] = "seq_dl";
inline const char KEY_TORRENT_FIRST_LAST_PIECE_PRIO[] = "f_l_piece_prio";
inline const char KEY_TORRENT_CATEGORY[] = "category";
inline const char KEY_TORRENT_TAGS[] = "tags";
inline const char KEY_TORRENT_SUPER_SEEDING[] = "super_seeding";
inline const char KEY_TORRENT_FORCE_START[] = "force_start";
inline const char KEY_TORRENT_SAVE_PATH[] = "save_path";
inline const char KEY_TORRENT_CONTENT_PATH[] = "content_path";
inline const char KEY_TORRENT_ADDED_ON[] = "added_on";
inline const char KEY_TORRENT_COMPLETION_ON[] = "completion_on";
inline const char KEY_TORRENT_TRACKER[] = "tracker";
inline const char KEY_TORRENT_TRACKERS_COUNT[] = "trackers_count";
inline const char KEY_TORRENT_DL_LIMIT[] = "dl_limit";
inline const char KEY_TORRENT_UP_LIMIT[] = "up_limit";
inline const char KEY_TORRENT_AMOUNT_DOWNLOADED[] = "downloaded";
inline const char KEY_TORRENT_AMOUNT_UPLOADED[] = "uploaded";
inline const char KEY_TORRENT_AMOUNT_DOWNLOADED_SESSION[] = "downloaded_session";
inline const char KEY_TORRENT_AMOUNT_UPLOADED_SESSION[] = "uploaded_session";
inline const char KEY_TORRENT_AMOUNT_LEFT[] = "amount_left";
inline const char KEY_TORRENT_AMOUNT_COMPLETED[] = "completed";
inline const char KEY_TORRENT_MAX_RATIO[] = "max_ratio";
inline const char KEY_TORRENT_MAX_SEEDING_TIME[] = "max_seeding_time";
inline const char KEY_TORRENT_RATIO_LIMIT[] = "ratio_limit";
inline const char KEY_TORRENT_SEEDING_TIME_LIMIT[] = "seeding_time_limit";
inline const char KEY_TORRENT_LAST_SEEN_COMPLETE_TIME[] = "seen_complete";
inline const char KEY_TORRENT_LAST_ACTIVITY_TIME[] = "last_activity";
inline const char KEY_TORRENT_TOTAL_SIZE[] = "total_size";
inline const char KEY_TORRENT_AUTO_TORRENT_MANAGEMENT[] = "auto_tmm";
inline const char KEY_TORRENT_TIME_ACTIVE[] = "time_active";
inline const char KEY_TORRENT_SEEDING_TIME[] = "seeding_time";
inline const char KEY_TORRENT_AVAILABILITY[] = "availability";
QVariantMap serialize(const BitTorrent::Torrent &torrent);

Loading…
Cancel
Save