1 # Example plugin to provide a new protocol
11 gi.require_version("Gtk", "3.0")
12 from gi.repository import Gtk, GLib
17 Internal data struct to hold ids to feature settings.
21 PrefDisableserverinput = 3
24 ToolSendCtrlAltDel = 6
30 Internal data struct to hold state.
33 self.connected = False
35 self.auth_called = False
36 self.auth_first = False
37 self.drawing_area = False
38 self.vnc_buffer = False
39 self.rgb_buffer = False
47 # This constructor is called before Remmina attempts to register the plugin since it this class has to be instantiated before registering it.
48 self.name = "A short name of the plugin that also appears in the 'Plugin' column in the main dialog."
49 # One of possible values: "pref", "tool", "entry", "protocol" or "secret". This value decides which methods are expected to be defined
51 self.type = "protocol"
52 self.description = "VNC but in Python!"
54 self.icon_name = "org.remmina.Remmina-vnc-symbolic"
55 self.icon_name_ssh = "org.remmina.Remmina-vnc-ssh-symbolic"
56 # Specifies which settings are available for this protocol
57 self.ssh_setting = remmina.PROTOCOL_SSH_SETTING_TUNNEL
59 self.gpdata = VncData()
60 self.qualities = ("0", "Poor Pixelmess", "1","Mhh kayy", "2","Nice", "9","hot sh*t")
61 # Define the features this module supports:
64 type=remmina.PROTOCOL_FEATURE_TYPE_PREF,
65 id=VncFeature.PrefQuality,
66 opt1=remmina.PROTOCOL_FEATURE_PREF_RADIO,
69 ,remmina.Feature(remmina.PROTOCOL_FEATURE_TYPE_PREF, VncFeature.PrefViewonly, remmina.PROTOCOL_FEATURE_PREF_CHECK, "viewonly", None)
70 ,remmina.Feature(remmina.PROTOCOL_FEATURE_TYPE_PREF, VncFeature.PrefDisableserverinput, remmina.PROTOCOL_SETTING_TYPE_CHECK, "disableserverinput", "Disable server input")
71 ,remmina.Feature(remmina.PROTOCOL_FEATURE_TYPE_TOOL, VncFeature.ToolRefresh, "Refresh", "face-smile", None)
72 ,remmina.Feature(remmina.PROTOCOL_FEATURE_TYPE_TOOL, VncFeature.ToolChat, "Open Chat…", "face-smile", None)
73 ,remmina.Feature(remmina.PROTOCOL_FEATURE_TYPE_TOOL, VncFeature.ToolSendCtrlAltDel, "Send Ctrl+Alt+Delete", None, None)
74 ,remmina.Feature(remmina.PROTOCOL_FEATURE_TYPE_SCALE, VncFeature.Scale, None, None, None)
75 ,remmina.Feature(remmina.PROTOCOL_FEATURE_TYPE_UNFOCUS, VncFeature.Unfocus, None, None, None)
78 colordepths = ("8", "256 colors (8 bpp)", "16", "High color (16 bpp)", "32", "True color (32 bpp)")
79 self.basic_settings = [
80 remmina.Setting(type=remmina.PROTOCOL_SETTING_TYPE_SERVER, name="server", label="", compact=False, opt1="_rfb._tcp",opt2=None)
81 , remmina.Setting(type=remmina.PROTOCOL_SETTING_TYPE_TEXT, name="proxy", label="Repeater", compact=False, opt1=None, opt2=None)
82 , remmina.Setting(type=remmina.PROTOCOL_SETTING_TYPE_TEXT, name="username", label="Username", compact=False, opt1=None, opt2=None)
83 , remmina.Setting(type=remmina.PROTOCOL_SETTING_TYPE_PASSWORD,name="password", label="User password",compact=False, opt1=None, opt2=None)
84 , remmina.Setting(type=remmina.PROTOCOL_SETTING_TYPE_SELECT, name="colordepth",label="Color depth", compact=False, opt1=colordepths,opt2=None)
85 , remmina.Setting(type=remmina.PROTOCOL_SETTING_TYPE_SELECT, name="quality", label="Quality", compact=False, opt1=self.qualities, opt2=None)
86 , remmina.Setting(type=remmina.PROTOCOL_SETTING_TYPE_KEYMAP, name="keymap", label="", compact=False, opt1=None, opt2=None)
88 self.advanced_settings = [
89 remmina.Setting(remmina.PROTOCOL_SETTING_TYPE_CHECK, "showcursor", "Show remote cursor", True, None, None)
90 , remmina.Setting(remmina.PROTOCOL_SETTING_TYPE_CHECK, "viewonly", "View only", False, None, None)
91 , remmina.Setting(remmina.PROTOCOL_SETTING_TYPE_CHECK, "disableclipboard", "Disable clipboard sync", True, None, None)
92 , remmina.Setting(remmina.PROTOCOL_SETTING_TYPE_CHECK, "disableencryption", "Disable encryption", False, None, None)
93 , remmina.Setting(remmina.PROTOCOL_SETTING_TYPE_CHECK, "disableserverinput", "Disable server input", True, None, None)
94 , remmina.Setting(remmina.PROTOCOL_SETTING_TYPE_CHECK, "disablepasswordstoring", "Disable password storing", True, None, None)
95 , remmina.Setting(remmina.PROTOCOL_SETTING_TYPE_CHECK, "disablesmoothscrolling", "Disable smooth scrolling", True, None, None)
99 # this is called when the plugin is loaded from Remmina.
100 cfile = gp.get_file()
101 self.gpdata.disable_smooth_scrolling = cfile.get_setting(key="disablesmoothscrolling", default=False)
102 self.gpdata.drawing_area = gp.get_viewport()
105 def open_connection(self, gp):
106 # Is called when the user wants to open a connection whith this plugin.
108 # Write code to initiate the connection. Example:
109 connection_file = gp.get_file()
110 connection_file.set_setting("disablepasswordstoring", False)
113 # Determine if passwords should not be allowed to be stored.
114 dont_save_passwords = connection_file.get_setting("disablepasswordstoring", False)
115 # Open a dialog prompting connection information and credentials
116 ret = remmina.protocol_plugin_init_auth(widget=gp,
117 flags= remmina.REMMINA_MESSAGE_PANEL_FLAG_USERNAME | remmina.REMMINA_MESSAGE_PANEL_FLAG_USERNAME_READONLY | remmina.REMMINA_MESSAGE_PANEL_FLAG_DOMAIN | remmina.REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD,
118 title="Python Rocks!",
120 default_password=connection_file.get_setting("password", ""),
122 password_prompt="Your Password Rocks!")
124 # Process the result of the dialog
125 if ret == Gtk.ResponseType.CANCEL:
127 elif ret == Gtk.ResponseType.OK:
128 # Indicate that the connection has been established!
129 remmina.protocol_plugin_signal_connection_opened(gp)
133 def close_connection(self, gp):
134 # The user requested to close the connection.
135 remmina.protocol_plugin_signal_connection_closed(gp)
137 def query_feature(self, gp, feature):
138 # Remmina asks if the given feature is available (remember Features registered in the construtor).
141 def map_event(self, gp):
142 # This is called when the widget is again on screen.
145 def unmap_event(self, gp):
146 # This is called when the widget is again not being shown on screen anymore. Any intensive graphical output
150 def call_feature(self, gp, feature):
151 # Remmina asks to execute on of the features.
153 if feature.type == remmina.REMMINA_PROTOCOL_FEATURE_TYPE_PREF and feature.id is VncFeature.PrefQuality:
155 quality = file.get_setting("quality", 0)
157 print("Ramping up graphics. Enjoy!")
159 print("Squeezing image into a few pixels...")
161 print("More the average guy, eh?")
163 print("Not great, not terrible...")
165 def send_keystrokes(self, gp, strokes):
166 # Remmina received a key stroke and wants to pass it to the remote.
169 def get_plugin_screenshot(self, gp, data):
170 # data is of type RemminaScreenshotData and should contain the raw pixels for the screenshot. Remmina takes care of storing it into a jpg.
171 # Return True when a screenshot has been done. Otherwise False.
174 # Instantiate & Register
176 remmina.register_plugin(myPlugin)