Commit 12ada72f authored by Jonh Wendell's avatar Jonh Wendell
Browse files

Added initial plugins/ssh folder

parent 73ba166c
# ssh plugin
plugindir = $(VINAGRE_PLUGINS_LIBS_DIR)
INCLUDES = \
-I$(top_srcdir) \
$(SSH_CFLAGS) \
$(WARN_CFLAGS) \
$(DISABLE_DEPRECATED_CFLAGS)
plugin_LTLIBRARIES = libssh.la
libssh_la_SOURCES = \
vinagre-ssh-plugin.h vinagre-ssh-plugin.c \
vinagre-ssh-connection.h vinagre-ssh-connection.c \
vinagre-ssh-tab.h vinagre-ssh-tab.c
libssh_la_LDFLAGS = $(PLUGIN_LIBTOOL_FLAGS)
libssh_la_LIBADD = $(SSH_LIBS)
plugin_in_files = ssh.vinagre-plugin.desktop.in
ssh.vinagre-plugin: ssh.vinagre-plugin.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
plugin_DATA = $(plugin_in_files:.vinagre-plugin.desktop.in=.vinagre-plugin)
EXTRA_DIST = $(plugin_in_files)
CLEANFILES = $(plugin_DATA)
DISTCLEANFILES = $(plugin_DATA)
-include $(top_srcdir)/git.mk
[Vinagre Plugin]
Module=ssh
IAge=1
_Name=SSH
_Description=SSH support
Authors=Jonh Wendell
Copyright=Copyright © 2009 Jonh Wendell
Website=http://www.bani.com.br
Version=1.0
Engine=1
Icon=vinagre
/*
* vinagre-ssh-connection.c
* Child class of abstract VinagreConnection, specific to SSH protocol
* This file is part of vinagre
*
* Copyright (C) 2009 - Jonh Wendell <wendell@bani.com.br>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <glib/gi18n.h>
#include <vinagre/vinagre-utils.h>
#include "vinagre-ssh-connection.h"
struct _VinagreSshConnectionPrivate
{
gint dummy;
};
#define VINAGRE_SSH_CONNECTION_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VINAGRE_TYPE_SSH_CONNECTION, VinagreSshConnectionPrivate))
G_DEFINE_TYPE (VinagreSshConnection, vinagre_ssh_connection, VINAGRE_TYPE_CONNECTION);
static void
vinagre_ssh_connection_init (VinagreSshConnection *conn)
{
conn->priv = G_TYPE_INSTANCE_GET_PRIVATE (conn, VINAGRE_TYPE_SSH_CONNECTION, VinagreSshConnectionPrivate);
}
static void
vinagre_ssh_connection_constructed (GObject *object)
{
vinagre_connection_set_protocol (VINAGRE_CONNECTION (object), "ssh");
}
static void
ssh_fill_writer (VinagreConnection *conn, xmlTextWriter *writer)
{
VINAGRE_CONNECTION_CLASS (vinagre_ssh_connection_parent_class)->impl_fill_writer (conn, writer);
}
static void
ssh_parse_item (VinagreConnection *conn, xmlNode *root)
{
VINAGRE_CONNECTION_CLASS (vinagre_ssh_connection_parent_class)->impl_parse_item (conn, root);
}
static void
vinagre_ssh_connection_class_init (VinagreSshConnectionClass *klass)
{
GObjectClass* object_class = G_OBJECT_CLASS (klass);
VinagreConnectionClass* parent_class = VINAGRE_CONNECTION_CLASS (klass);
g_type_class_add_private (klass, sizeof (VinagreSshConnectionPrivate));
object_class->constructed = vinagre_ssh_connection_constructed;
parent_class->impl_fill_writer = ssh_fill_writer;
parent_class->impl_parse_item = ssh_parse_item;
}
VinagreConnection *
vinagre_ssh_connection_new (void)
{
return VINAGRE_CONNECTION (g_object_new (VINAGRE_TYPE_SSH_CONNECTION, NULL));
}
/* vim: set ts=8: */
/*
* vinagre-ssh-connection.h
* Child class of abstract VinagreConnection, specific to SSH protocol
* This file is part of vinagre
*
* Copyright (C) 2009 - Jonh Wendell <wendell@bani.com.br>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __VINAGRE_SSH_CONNECTION_H__
#define __VINAGRE_SSH_CONNECTION_H__
#include <vinagre/vinagre-connection.h>
G_BEGIN_DECLS
#define VINAGRE_TYPE_SSH_CONNECTION (vinagre_ssh_connection_get_type ())
#define VINAGRE_SSH_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VINAGRE_TYPE_SSH_CONNECTION, VinagreSshConnection))
#define VINAGRE_SSH_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VINAGRE_TYPE_SSH_CONNECTION, VinagreSshConnectionClass))
#define VINAGRE_IS_SSH_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VINAGRE_TYPE_SSH_CONNECTION))
#define VINAGRE_IS_SSH_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VINAGRE_TYPE_SSH_CONNECTION))
#define VINAGRE_SSH_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VINAGRE_TYPE_SSH_CONNECTION, VinagreSshConnectionClass))
typedef struct _VinagreSshConnectionClass VinagreSshConnectionClass;
typedef struct _VinagreSshConnection VinagreSshConnection;
typedef struct _VinagreSshConnectionPrivate VinagreSshConnectionPrivate;
struct _VinagreSshConnectionClass
{
VinagreConnectionClass parent_class;
};
struct _VinagreSshConnection
{
VinagreConnection parent_instance;
VinagreSshConnectionPrivate *priv;
};
GType vinagre_ssh_connection_get_type (void) G_GNUC_CONST;
VinagreConnection* vinagre_ssh_connection_new (void);
G_END_DECLS
#endif /* __VINAGRE_SSH_CONNECTION_H__ */
/* vim: set ts=8: */
/*
* vinagre-ssh-plugin.c
* This file is part of vinagre
*
* Copyright (C) 2009 Jonh Wendell <wendell@bani.com.br>
*
* vinagre-ssh-plugin.c is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* vinagre-ssh-plugin.c is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <glib/gi18n-lib.h>
#include <gmodule.h>
#include <vinagre/vinagre-debug.h>
#include "vinagre-ssh-plugin.h"
#include "vinagre-ssh-connection.h"
#include "vinagre-ssh-tab.h"
#define VINAGRE_SSH_PLUGIN_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), VINAGRE_TYPE_SSH_PLUGIN, VinagreSshPluginPrivate))
VINAGRE_PLUGIN_REGISTER_TYPE(VinagreSshPlugin, vinagre_ssh_plugin)
static void
impl_activate (VinagrePlugin *plugin,
VinagreWindow *window)
{
vinagre_debug_message (DEBUG_PLUGINS, "VinagreSshPlugin Activate");
}
static void
impl_deactivate (VinagrePlugin *plugin,
VinagreWindow *window)
{
vinagre_debug_message (DEBUG_PLUGINS, "VinagreSshPlugin Deactivate");
}
static void
impl_update_ui (VinagrePlugin *plugin,
VinagreWindow *window)
{
vinagre_debug_message (DEBUG_PLUGINS, "VinagreSshPlugin Update UI");
}
static const gchar *
impl_get_protocol (VinagrePlugin *plugin)
{
return "ssh";
}
static gchar **
impl_get_public_description (VinagrePlugin *plugin)
{
gchar **result = g_new (gchar *, 3);
result[0] = g_strdup (_("SSH"));
/* Translators: This is a description of the SSH protocol. It appears at Connect dialog. */
result[1] = g_strdup (_("Access Unix/Linux terminals"));
result[2] = NULL;
return result;
}
static const gchar *
impl_get_mdns_service (VinagrePlugin *plugin)
{
return "_ssh._tcp";
}
static VinagreConnection *
impl_new_connection (VinagrePlugin *plugin)
{
return vinagre_ssh_connection_new ();
}
static GtkWidget *
impl_new_tab (VinagrePlugin *plugin,
VinagreConnection *conn,
VinagreWindow *window)
{
return vinagre_ssh_tab_new (conn, window);
}
static gint
impl_get_default_port (VinagrePlugin *plugin)
{
return 22;
}
static void
vinagre_ssh_plugin_init (VinagreSshPlugin *plugin)
{
vinagre_debug_message (DEBUG_PLUGINS, "VinagreSshPlugin initializing");
}
static void
vinagre_ssh_plugin_finalize (GObject *object)
{
vinagre_debug_message (DEBUG_PLUGINS, "VinagreSshPlugin finalizing");
G_OBJECT_CLASS (vinagre_ssh_plugin_parent_class)->finalize (object);
}
static void
vinagre_ssh_plugin_class_init (VinagreSshPluginClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
VinagrePluginClass *plugin_class = VINAGRE_PLUGIN_CLASS (klass);
object_class->finalize = vinagre_ssh_plugin_finalize;
plugin_class->activate = impl_activate;
plugin_class->deactivate = impl_deactivate;
plugin_class->update_ui = impl_update_ui;
plugin_class->get_protocol = impl_get_protocol;
plugin_class->get_public_description = impl_get_public_description;
plugin_class->new_connection = impl_new_connection;
plugin_class->get_mdns_service = impl_get_mdns_service;
plugin_class->new_tab = impl_new_tab;
plugin_class->get_default_port = impl_get_default_port;
}
/* vim: set ts=8: */
/*
* vinagre-ssh-plugin.h
* This file is part of vinagre
*
* Copyright (C) 2009 Jonh Wendell <wendell@bani.com.br>
*
* vinagre-ssh-plugin.h is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* vinagre-ssh-plugin.h is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __VINAGRE_SSH_PLUGIN_H__
#define __VINAGRE_SSH_PLUGIN_H__
#include <glib.h>
#include <glib-object.h>
#include <vinagre/vinagre-plugin.h>
G_BEGIN_DECLS
/*
* Type checking and casting macros
*/
#define VINAGRE_TYPE_SSH_PLUGIN (vinagre_ssh_plugin_get_type ())
#define VINAGRE_SSH_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), VINAGRE_TYPE_SSH_PLUGIN, VinagreSshPlugin))
#define VINAGRE_SSH_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), VINAGRE_TYPE_SSH_PLUGIN, VinagreSshPluginClass))
#define VINAGRE_IS_SSH_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), VINAGRE_TYPE_SSH_PLUGIN))
#define VINAGRE_IS_SSH_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), VINAGRE_TYPE_SSH_PLUGIN))
#define VINAGRE_SSH_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), VINAGRE_TYPE_SSH_PLUGIN, VinagreSshPluginClass))
/* Private structure type */
typedef struct _VinagreSshPluginPrivate VinagreSshPluginPrivate;
/*
* Main object structure
*/
typedef struct _VinagreSshPlugin VinagreSshPlugin;
struct _VinagreSshPlugin
{
VinagrePlugin parent_instance;
};
/*
* Class definition
*/
typedef struct _VinagreSshPluginClass VinagreSshPluginClass;
struct _VinagreSshPluginClass
{
VinagrePluginClass parent_class;
};
/*
* Public methods
*/
GType vinagre_ssh_plugin_get_type (void) G_GNUC_CONST;
/* All the plugins must implement this function */
G_MODULE_EXPORT GType register_vinagre_plugin (GTypeModule *module);
G_END_DECLS
#endif /* __VINAGRE_SSH_PLUGIN_H__ */
/* vim: set ts=8: */
/*
* vinagre-ssh-tab.c
* SSH Implementation for VinagreSshTab widget
* This file is part of vinagre
*
* Copyright (C) 2009 - Jonh Wendell <wendell@bani.com.br>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <glib/gi18n.h>
#include <vte/vte.h>
#include <gdk/gdkkeysyms.h>
#include <vinagre/vinagre-utils.h>
#include <vinagre/vinagre-prefs.h>
#include "vinagre-ssh-tab.h"
#include "vinagre-ssh-connection.h"
#define VINAGRE_SSH_TAB_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), VINAGRE_TYPE_SSH_TAB, VinagreSshTabPrivate))
struct _VinagreSshTabPrivate
{
GtkWidget *vte;
};
G_DEFINE_TYPE (VinagreSshTab, vinagre_ssh_tab, VINAGRE_TYPE_TAB)
static void open_ssh (VinagreSshTab *ssh_tab);
static gchar *
ssh_tab_get_tooltip (VinagreTab *tab)
{
VinagreConnection *conn = vinagre_tab_get_conn (tab);
return g_markup_printf_escaped (
"<b>%s</b> %s\n"
"<b>%s</b> %d",
_("Host:"), vinagre_connection_get_host (conn),
_("Port:"), vinagre_connection_get_port (conn));
}
static GdkPixbuf *
ssh_tab_get_screenshot (VinagreTab *tab)
{
return NULL;
}
static void
vinagre_ssh_tab_constructed (GObject *object)
{
open_ssh (VINAGRE_SSH_TAB (object));
}
static void
vinagre_ssh_tab_class_init (VinagreSshTabClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
VinagreTabClass* tab_class = VINAGRE_TAB_CLASS (klass);
object_class->constructed = vinagre_ssh_tab_constructed;
tab_class->impl_get_tooltip = ssh_tab_get_tooltip;
tab_class->impl_get_screenshot = ssh_tab_get_screenshot;
g_type_class_add_private (object_class, sizeof (VinagreSshTabPrivate));
}
static void
open_ssh (VinagreSshTab *ssh_tab)
{
gchar **arg;
arg = g_new (gchar *, 5);
arg[0] = g_strdup ("ssh");
arg[1] = g_strdup (vinagre_connection_get_host (vinagre_tab_get_conn (VINAGRE_TAB (ssh_tab))));
arg[3] = g_strdup ("-p");
arg[4] = g_strdup_printf ("%d", vinagre_connection_get_port (vinagre_tab_get_conn (VINAGRE_TAB (ssh_tab))));
arg[5] = NULL;
vte_terminal_fork_command (VTE_TERMINAL (ssh_tab->priv->vte),
"ssh",
arg,
NULL,
NULL,
FALSE,
FALSE,
FALSE);
g_strfreev (arg);
gtk_widget_show_all (GTK_WIDGET (ssh_tab));
}
static void
ssh_disconnected_cb (VteTerminal *ssh, VinagreSshTab *tab)
{
g_signal_emit_by_name (G_OBJECT (tab), "tab-disconnected");
}
static void
vinagre_ssh_tab_init (VinagreSshTab *ssh_tab)
{
ssh_tab->priv = VINAGRE_SSH_TAB_GET_PRIVATE (ssh_tab);
/* Create the ssh widget */
ssh_tab->priv->vte = vte_terminal_new ();
vinagre_tab_add_view (VINAGRE_TAB (ssh_tab), ssh_tab->priv->vte);
g_signal_connect (ssh_tab->priv->vte,
"child-exited",
G_CALLBACK (ssh_disconnected_cb),
ssh_tab);
}
GtkWidget *
vinagre_ssh_tab_new (VinagreConnection *conn,
VinagreWindow *window)
{
return GTK_WIDGET (g_object_new (VINAGRE_TYPE_SSH_TAB,
"conn", conn,
"window", window,
NULL));
}
/* vim: set ts=8: */
/*
* vinagre-ssh-tab.h
* SSH Tab
* This file is part of vinagre
*
* Copyright (C) 2009 - Jonh Wendell <wendell@bani.com.br>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __VINAGRE_SSH_TAB_H__
#define __VINAGRE_SSH_TAB_H__
#include <vinagre/vinagre-tab.h>
G_BEGIN_DECLS
#define VINAGRE_TYPE_SSH_TAB (vinagre_ssh_tab_get_type())
#define VINAGRE_SSH_TAB(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), VINAGRE_TYPE_SSH_TAB, VinagreSshTab))
#define VINAGRE_SSH_TAB_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), VINAGRE_TYPE_SSH_TAB, VinagreSshTab const))
#define VINAGRE_SSH_TAB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), VINAGRE_TYPE_SSH_TAB, VinagreSshTabClass))
#define VINAGRE_IS_SSH_TAB(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), VINAGRE_TYPE_SSH_TAB))
#define VINAGRE_IS_SSH_TAB_CLASS(klass)...(G_TYPE_CHECK_CLASS_TYPE ((klass), VINAGRE_TYPE_SSH_TAB))
#define VINAGRE_SSH_TAB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), VINAGRE_TYPE_SSH_TAB, VinagreSshTabClass))
typedef struct _VinagreSshTabPrivate VinagreSshTabPrivate;
typedef struct _VinagreSshTab VinagreSshTab;
typedef struct _VinagreSshTabClass VinagreSshTabClass;
struct _VinagreSshTab
{
VinagreTab tab;
VinagreSshTabPrivate *priv;
};
struct _VinagreSshTabClass
{
VinagreTabClass parent_class;
};
GType vinagre_ssh_tab_get_type (void) G_GNUC_CONST;
GtkWidget * vinagre_ssh_tab_new (VinagreConnection *conn,
VinagreWindow *window);
G_END_DECLS
#endif /* __VINAGRE_SSH_TAB_H__ */
/* vim: set ts=8: */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment