VgaGames4

VgaGames4 - dialog man-pages

[.. upper level ..]

# vg4->dialog->nw_connect()

Open a canvas-dialog for specifying network-server and connect to it.

SYNTAX
VG_BOOL vg4->dialog->nw_connect(VG_BOOL *do_connect, char *svname, size_t svsize, const char *cvasdir, const struct VG_Position *posdst, struct VG_Hash *hvar)
FUNCTION PARAMETERS

do_connect | For returning whether ready to connect - VG_TRUE = OK, connect-button was clicked - VG_FALSE = Cancel-button was clicked
svname | For passing default server-name and returning server-name - if set after return, server-name was typed in - if empty after return, server-name shall be searched via broadcast/multicast
svsize | Size of svname
cvasdir | Directory to load canvasses from, or NULL = use system-canvasses
posdst | Canvas-position on window, or NULL = centered
hvar | Hash with variable-values (see vg4->canvas->load())

RETURN VALUE
Returns boolean: - VG_TRUE: OK - VG_FALSE: Got exit-request
DESCRIPTION
Open a canvas-dialog for specifying network-server. This function uses following canvas-file (installed below share/vgagames4/canvas/) - nw.connect.cvas: Top-canvas The parameter hvar should contain following variables - key: connect:title value: title of top-canvas - key: connect:info-on value: text for info, when searching for network-server - key: connect:info-off value: text for info, when network-server must be typed in If the returned do_connect is VG_FALSE, the function was cancelled. If the returned svname is empty, the server shall be searched via broadcast/multicast. If own canvas-files shall be used instead of the system-canvas-files, they must lay in cvasdir or cvasdir/network/ and have the same names as the system-canvas-files: - nw.connect.cvas - uses canvas-items: - [CV-TEXT] with name title: text for title - [CV-TEXT] with name info: text for connection-type (variables connect:info-on, connect:info-off), e.g. "Search for network-server" and "Input network-server" - [CV-SWITCH] with name switch: for setting whether server-name is being searched or typed in - [CV-INPUT] with name input: for typing in server-name - [CV-BUTTON] with name connect: for being ready to connect - [CV-BUTTON] as a cancel-button - uses variables: - key: title value: title of canvas
EXAMPLE

      struct VG_Hash *hvar;
      char svname[256];
      VG_BOOL do_connect;

      hvar = vg4->hash->create();

      /* set variables */
      vg4->hash->setstr(hvar, "connect:title", "Specify network-server");
      vg4->hash->setstr(hvar, "connect:info-on", "Search for network-server");
      vg4->hash->setstr(hvar, "connect:info-off", "Input network-server");

      /* execute dialog */
      *svname = '\0';  /* no default server-name */
      if (!vg4->dialog->nw_connect(&do_connect, svname, sizeof(svname), NULL, NULL, hvar)) {
        /* exit request */
        VG_dest();
        exit(0);
      }

      vg4->hash->destroy(hvar);

      if (do_connect) {  /* not cancelled */
        if (*svname != '\0') {
          printf("Servername to connect to: %s\n", svname);
        } else {
          printf("Servername to connect to must be detected via broadcast/multicast\n");
        }
      }