Freeciv21
Develop your civilization from humble roots to a global empire
servers.cpp File Reference
#include <fc_config.h>
#include "servers.h"
#include <QBuffer>
#include <QByteArray>
#include <QEventLoop>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QUdpSocket>
#include <QUrlQuery>
#include "cvercmp.h"
#include "net_types.h"
#include "registry_ini.h"
#include "fc_version.h"
#include "capstr.h"
#include "dataio_raw.h"
#include "version.h"
#include "chatline.h"
#include "client_main.h"
+ Include dependency graph for servers.cpp:

Go to the source code of this file.

Classes

struct  server_scan
 

Functions

static bool begin_metaserver_scan (struct server_scan *scan)
 Begin a metaserver scan for servers. More...
 
static void delete_server_list (struct server_list *server_list)
 Frees everything associated with a server list including the server list itself (so the server_list is no longer valid after calling this function) More...
 
static struct server_list * parse_metaserver_data (QIODevice *f)
 The server sends a stream in a registry 'ini' type format. More...
 
static bool meta_read_response (struct server_scan *scan)
 Read the reply string from the metaserver. More...
 
static void metaserver_scan (void *arg)
 Metaserver scan thread entry point. More...
 
struct server_scanserver_scan_begin (enum server_scan_type type, ServerScanErrorFunc error_func)
 Creates a new server scan and returns it, or nullptr if impossible. More...
 
enum server_scan_type server_scan_get_type (const struct server_scan *scan)
 A simple query function to determine the type of a server scan (previously allocated in server_scan_begin). More...
 
enum server_scan_status server_scan_poll (struct server_scan *scan)
 A function to query servers of the server scan. More...
 
struct server_list * server_scan_get_list (struct server_scan *scan)
 Returns the srv_list currently held by the scan (may be nullptr). More...
 
void server_scan_finish (struct server_scan *scan)
 Closes the socket listening on the scan, frees the list of servers, and frees the memory allocated for 'scan' by server_scan_begin(). More...
 

Variables

enum announce_type announce
 

Function Documentation

◆ begin_metaserver_scan()

static bool begin_metaserver_scan ( struct server_scan scan)
static

Begin a metaserver scan for servers.

Returns FALSE on error (in which case errbuf will contain an error message).

Definition at line 421 of file servers.cpp.

Referenced by metaserver_scan().

◆ delete_server_list()

static void delete_server_list ( struct server_list *  server_list)
static

Frees everything associated with a server list including the server list itself (so the server_list is no longer valid after calling this function)

Definition at line 473 of file servers.cpp.

◆ meta_read_response()

static bool meta_read_response ( struct server_scan scan)
static

Read the reply string from the metaserver.

Definition at line 367 of file servers.cpp.

Referenced by metaserver_scan().

◆ metaserver_scan()

static void metaserver_scan ( void *  arg)
static

Metaserver scan thread entry point.

Definition at line 398 of file servers.cpp.

Referenced by server_scan_begin().

◆ parse_metaserver_data()

static struct server_list* parse_metaserver_data ( QIODevice *  f)
static

The server sends a stream in a registry 'ini' type format.

Read it using secfile functions and fill the server_list structs.

Definition at line 250 of file servers.cpp.

Referenced by meta_read_response().

◆ server_scan_begin()

struct server_scan* server_scan_begin ( enum server_scan_type  type,
ServerScanErrorFunc  error_func 
)

Creates a new server scan and returns it, or nullptr if impossible.

Depending on 'type' the scan will look for either local or internet games.

error_func provides a callback to be used in case of error; this callback probably should call server_scan_finish.

NB: You must call server_scan_finish() when you are done with the scan to free the memory and resources allocated by it.

Definition at line 518 of file servers.cpp.

Referenced by page_network::update_network_lists().

◆ server_scan_finish()

void server_scan_finish ( struct server_scan scan)

Closes the socket listening on the scan, frees the list of servers, and frees the memory allocated for 'scan' by server_scan_begin().

Definition at line 607 of file servers.cpp.

Referenced by page_network::destroy_server_scans().

◆ server_scan_get_list()

struct server_list* server_scan_get_list ( struct server_scan scan)

Returns the srv_list currently held by the scan (may be nullptr).

Definition at line 594 of file servers.cpp.

Referenced by page_network::check_server_scan(), and page_network::slot_selection_changed().

◆ server_scan_get_type()

enum server_scan_type server_scan_get_type ( const struct server_scan scan)

A simple query function to determine the type of a server scan (previously allocated in server_scan_begin).

Definition at line 518 of file servers.cpp.

Referenced by page_network::check_server_scan().

◆ server_scan_poll()

enum server_scan_status server_scan_poll ( struct server_scan scan)

A function to query servers of the server scan.

This will check any pending network data and update the server list.

The return value indicates the status of the server scan: SCAN_STATUS_ERROR - The scan failed and should be aborted. SCAN_STATUS_WAITING - The scan is in progress (continue polling). SCAN_STATUS_PARTIAL - The scan received some data, with more expected. Get the servers with server_scan_get_list(), and continue polling. SCAN_STATUS_DONE - The scan received all data it expected to receive. Get the servers with server_scan_get_list(), and stop calling this function. SCAN_STATUS_ABORT - The scan has been aborted

Definition at line 518 of file servers.cpp.

Referenced by page_network::check_server_scan().

Variable Documentation

◆ announce

enum announce_type announce
extern

Definition at line 134 of file client_main.cpp.

Referenced by fcUdpScan::begin_scan(), client_main(), and remove_trade_route().