~noskcaj/ubuntu/vivid/remmina/1.1.2

« back to all changes in this revision

Viewing changes to src/remminaplug.c

  • Committer: Bazaar Package Importer
  • Author(s): Luca Falavigna
  • Date: 2010-01-26 20:17:14 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20100126201714-i80t3aighmpv64i1
Tags: 0.7.3-1
* New upstream release.
  - Allow connecting to a VNC server via SSH tunnel by specifying
    display number instead of TCP port (Closes: #563969).

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
#include <gtk/gtk.h>
22
22
#include <glib/gi18n.h>
 
23
#include <stdlib.h>
23
24
#include "config.h"
24
25
#include "remminapublic.h"
25
26
#include "remminapref.h"
347
348
#endif
348
349
 
349
350
gchar*
350
 
remmina_plug_start_direct_tunnel (RemminaPlug *gp, gint default_port)
 
351
remmina_plug_start_direct_tunnel (RemminaPlug *gp, gint default_port, gboolean port_plus)
351
352
{
352
 
    gchar *dest;
 
353
    gchar *dest, *ptr;
 
354
    gint port;
353
355
 
354
356
    if (remmina_file_is_incoming (gp->remmina_file))
355
357
    {
361
363
        {
362
364
            dest = g_strdup_printf ("%s:%i", gp->remmina_file->server, default_port);
363
365
        }
 
366
        else if (port_plus)
 
367
        {
 
368
            dest = g_strdup (gp->remmina_file->server);
 
369
            /* Protocols like VNC supports using instance number :0, :1, etc as port number. */
 
370
            ptr = strchr (dest, ':');
 
371
            port = atoi (ptr + 1);
 
372
            if (port < 100)
 
373
            {
 
374
                port += default_port;
 
375
                *ptr = '\0';
 
376
                ptr = dest;
 
377
                dest = g_strdup_printf ("%s:%i", ptr, port);
 
378
                g_free (ptr);
 
379
            }
 
380
        }
364
381
        else
365
382
        {
366
383
            dest = g_strdup (gp->remmina_file->server);
410
427
}
411
428
 
412
429
gboolean
413
 
remmina_plug_start_xport_tunnel (RemminaPlug *gp, gint display,
 
430
remmina_plug_start_xport_tunnel (RemminaPlug *gp,
414
431
    RemminaSSHTunnelCallback init_func,
415
432
    RemminaSSHTunnelCallback connect_func,
416
433
    RemminaSSHTunnelCallback disconnect_func,
431
448
    bindlocalhost = (g_strcmp0 (REMMINA_SSH (gp->ssh_tunnel)->server, server) == 0);
432
449
    g_free (server);
433
450
 
434
 
    if (!remmina_ssh_tunnel_xport (gp->ssh_tunnel, display, bindlocalhost))
 
451
    if (!remmina_ssh_tunnel_xport (gp->ssh_tunnel, bindlocalhost))
435
452
    {
436
453
        g_snprintf (gp->error_message, MAX_ERROR_LENGTH,
437
454
            "Failed to open channel : %s", ssh_get_error (REMMINA_SSH (gp->ssh_tunnel)->session));
446
463
#endif
447
464
}
448
465
 
 
466
void
 
467
remmina_plug_set_display (RemminaPlug *gp, gint display)
 
468
{
 
469
    if (gp->ssh_tunnel->localdisplay) g_free (gp->ssh_tunnel->localdisplay);
 
470
    gp->ssh_tunnel->localdisplay = g_strdup_printf ("unix:%i", display);
 
471
}
 
472