Crossfire Client, Trunk  R20507
Enumerations | Functions | Variables
metaserver.c File Reference

Supports the client's metaserver dialog used to connect to available servers. More...

#include "client.h"
#include <gtk/gtk.h>
#include <stdbool.h>
#include "image.h"
#include "main.h"
#include "metaserver.h"
#include "gtk2proto.h"
Include dependency graph for metaserver.c:

Go to the source code of this file.

Enumerations

enum  {
  LIST_HOSTNAME, LIST_IPADDR, LIST_PLAYERS, LIST_VERSION,
  LIST_COMMENT
}
 

Functions

static void metaserver_connect_to (const char *name)
 Connect to a server with the given hostname and optional port number. More...
 
void metaserver_show_prompt ()
 Constructs the metaserver dialog and handles metaserver selection. More...
 
void metaserver_ui_init ()
 Initialize the metaserver user interface. More...
 
void on_button_metaserver_quit_pressed (GtkButton *button, gpointer user_data)
 Quits the client application if the quit button is pressed. More...
 
void on_metaserver_select_clicked (GtkButton *button, gpointer user_data)
 Establish a connection with the server when pressing the connect button. More...
 
static gboolean on_selection_changed ()
 Copy the selected server to the server entry box. More...
 
static gboolean on_server_entry_changed ()
 Activate the connect button and unselect servers if keys are pressed to enter a server name. More...
 
static void server_add (char *server, int update, int players, char *version, char *comment, bool compatible)
 
static bool server_exists (const char *server)
 Check if the given server is already in the server list. More...
 
static gpointer server_fetch ()
 Wrapper on top of ms_fetch() for a GThread. More...
 

Variables

static GtkWidget * metaserver_button
 
static GtkWidget * metaserver_entry
 
static GtkTreeSelection * metaserver_selection
 
static GtkWidget * metaserver_status
 
static GtkWidget * metaserver_window
 
static GtkListStore * store_metaserver
 
static GtkWidget * treeview_metaserver
 

Detailed Description

Supports the client's metaserver dialog used to connect to available servers.

Definition in file metaserver.c.

Enumeration Type Documentation

anonymous enum
Enumerator
LIST_HOSTNAME 
LIST_IPADDR 
LIST_PLAYERS 
LIST_VERSION 
LIST_COMMENT 

Definition at line 35 of file metaserver.c.

Function Documentation

static void metaserver_connect_to ( const char *  name)
static

Connect to a server with the given hostname and optional port number.

Parameters
nameThe DNS name of a server to connect to. If the server operates on a non-standard port, a colon and the port number is appended to the DNS name. For example: localhost:8000

Definition at line 227 of file metaserver.c.

References client_connect(), cpl, csocket, ClientSocket::fd, Player_Struct::input_state, LOG(), LOG_DEBUG, metaserver_status, metaserver_window, and Playing.

Referenced by on_metaserver_select_clicked().

Here is the call graph for this function:

Here is the caller graph for this function:

void metaserver_show_prompt ( void  )

Constructs the metaserver dialog and handles metaserver selection.

If the player has a servers.cache file in their .crossfire folder, the cached server list is added to the contents of the metaserver dialog.

Definition at line 198 of file metaserver.c.

References cpl, hide_all_login_windows(), Player_Struct::input_state, Metaserver_Select, metaserver_status, metaserver_window, on_server_entry_changed(), server_fetch(), store_metaserver, and treeview_metaserver.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

void metaserver_ui_init ( )
void on_button_metaserver_quit_pressed ( GtkButton *  button,
gpointer  user_data 
)

Quits the client application if the quit button is pressed.

This is also used to quit the client if the button's accelerator is pressed.

Parameters
button
user_data

Definition at line 266 of file metaserver.c.

References on_window_destroy_event().

Referenced by metaserver_ui_init().

Here is the call graph for this function:

Here is the caller graph for this function:

void on_metaserver_select_clicked ( GtkButton *  button,
gpointer  user_data 
)

Establish a connection with the server when pressing the connect button.

Parameters
button
user_data

Definition at line 252 of file metaserver.c.

References metaserver_connect_to(), and metaserver_entry.

Referenced by metaserver_ui_init().

Here is the call graph for this function:

Here is the caller graph for this function:

static gboolean on_selection_changed ( )
static

Copy the selected server to the server entry box.

Definition at line 40 of file metaserver.c.

References LIST_HOSTNAME, metaserver_button, metaserver_entry, and metaserver_selection.

Referenced by metaserver_ui_init().

Here is the caller graph for this function:

static gboolean on_server_entry_changed ( )
static

Activate the connect button and unselect servers if keys are pressed to enter a server name.

Definition at line 58 of file metaserver.c.

References metaserver_button, metaserver_entry, and metaserver_selection.

Referenced by metaserver_show_prompt(), and metaserver_ui_init().

Here is the caller graph for this function:

static void server_add ( char *  server,
int  update,
int  players,
char *  version,
char *  comment,
bool  compatible 
)
static

Definition at line 173 of file metaserver.c.

References LIST_COMMENT, LIST_HOSTNAME, LIST_IPADDR, LIST_PLAYERS, LIST_VERSION, server_exists(), and store_metaserver.

Referenced by server_fetch().

Here is the call graph for this function:

Here is the caller graph for this function:

static bool server_exists ( const char *  server)
static

Check if the given server is already in the server list.

Definition at line 155 of file metaserver.c.

References LIST_HOSTNAME, name, and store_metaserver.

Referenced by server_add().

Here is the caller graph for this function:

static gpointer server_fetch ( )
static

Wrapper on top of ms_fetch() for a GThread.

Returns
NULL

Definition at line 188 of file metaserver.c.

References ms_fetch(), and server_add().

Referenced by metaserver_show_prompt().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

GtkWidget * metaserver_button
static

Definition at line 30 of file metaserver.c.

Referenced by metaserver_ui_init(), on_selection_changed(), and on_server_entry_changed().

GtkWidget * metaserver_entry
static
GtkTreeSelection* metaserver_selection
static

Definition at line 33 of file metaserver.c.

Referenced by metaserver_ui_init(), on_selection_changed(), and on_server_entry_changed().

GtkWidget * metaserver_status
static

Definition at line 30 of file metaserver.c.

Referenced by metaserver_connect_to(), metaserver_show_prompt(), and metaserver_ui_init().

GtkWidget* metaserver_window
static

Definition at line 30 of file metaserver.c.

Referenced by metaserver_connect_to(), metaserver_show_prompt(), and metaserver_ui_init().

GtkListStore* store_metaserver
static

Definition at line 32 of file metaserver.c.

Referenced by metaserver_show_prompt(), metaserver_ui_init(), server_add(), and server_exists().

GtkWidget * treeview_metaserver
static

Definition at line 30 of file metaserver.c.

Referenced by metaserver_show_prompt(), and metaserver_ui_init().