Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 1 | /* |
Guillaume Roguez | 2a6150d | 2017-07-19 18:24:47 -0400 | [diff] [blame^] | 2 | * Copyright (C) 2015-2017 Savoir-faire Linux Inc. |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 3 | * Author: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 18 | */ |
| 19 | |
| 20 | #include "accountadvancedtab.h" |
| 21 | |
| 22 | #include <gtk/gtk.h> |
aviau | 922473c | 2016-12-12 17:49:55 -0500 | [diff] [blame] | 23 | #include <glib/gi18n.h> |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 24 | #include <account.h> |
aviau | 922473c | 2016-12-12 17:49:55 -0500 | [diff] [blame] | 25 | #include "models/gtkqtreemodel.h" |
| 26 | #include "utils/models.h" |
| 27 | #include "defines.h" |
| 28 | #include <bootstrapmodel.h> |
aviau | 5d3e40a | 2016-12-12 15:33:10 -0500 | [diff] [blame] | 29 | #include "accountaudiotab.h" |
| 30 | #include "accountvideotab.h" |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 31 | |
| 32 | struct _AccountAdvancedTab |
| 33 | { |
| 34 | GtkBox parent; |
| 35 | }; |
| 36 | |
| 37 | struct _AccountAdvancedTabClass |
| 38 | { |
| 39 | GtkBoxClass parent_class; |
| 40 | }; |
| 41 | |
| 42 | typedef struct _AccountAdvancedTabPrivate AccountAdvancedTabPrivate; |
| 43 | |
| 44 | struct _AccountAdvancedTabPrivate |
| 45 | { |
| 46 | Account *account; |
| 47 | GtkWidget *vbox_main; |
| 48 | GtkWidget *frame_registration; |
Stepan Salenikovich | 2371a89 | 2015-07-23 17:17:00 -0400 | [diff] [blame] | 49 | GtkWidget *box_registration; |
| 50 | GtkWidget *box_registration_expire; |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 51 | GtkWidget *adjustment_registration_timeout; |
Stepan Salenikovich | 2371a89 | 2015-07-23 17:17:00 -0400 | [diff] [blame] | 52 | GtkWidget *checkbutton_allow_incoming_unknown; |
| 53 | GtkWidget *checkbutton_allow_incoming_history; |
| 54 | GtkWidget *checkbutton_allow_incoming_contacts; |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 55 | GtkWidget *frame_network_interface; |
| 56 | GtkWidget *box_network_interface; |
| 57 | GtkWidget *checkbutton_use_random_port; |
| 58 | GtkWidget *box_local_port; |
| 59 | GtkWidget *adjustment_local_port; |
| 60 | GtkWidget *radiobutton_same_as_local; |
| 61 | GtkWidget *radiobutton_set_published; |
| 62 | GtkWidget *box_published_address_port; |
| 63 | GtkWidget *entry_published_address; |
| 64 | GtkWidget *spinbutton_published_port; |
| 65 | GtkWidget *adjustment_published_port; |
| 66 | GtkWidget *checkbutton_use_stun; |
Stepan Salenikovich | 28c1f0c | 2015-08-06 11:42:41 -0400 | [diff] [blame] | 67 | GtkWidget *grid_stun; |
| 68 | GtkWidget *entry_stunserver; |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 69 | GtkWidget *checkbutton_use_turn; |
Stepan Salenikovich | 28c1f0c | 2015-08-06 11:42:41 -0400 | [diff] [blame] | 70 | GtkWidget *grid_turn; |
| 71 | GtkWidget *entry_turnserver; |
| 72 | GtkWidget *entry_turnusername; |
| 73 | GtkWidget *entry_turnpassword; |
| 74 | GtkWidget *entry_turnrealm; |
aviau | cbb2fc4 | 2016-12-12 15:55:24 -0500 | [diff] [blame] | 75 | GtkWidget *frame_ice_fallback; |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 76 | GtkWidget *adjustment_audio_port_min; |
| 77 | GtkWidget *adjustment_audio_port_max; |
| 78 | GtkWidget *adjustment_video_port_min; |
| 79 | GtkWidget *adjustment_video_port_max; |
aviau | 922473c | 2016-12-12 17:49:55 -0500 | [diff] [blame] | 80 | GtkWidget *box_bootstrap_servers; |
aviau | 5d3e40a | 2016-12-12 15:33:10 -0500 | [diff] [blame] | 81 | GtkWidget *frame_bootstrap_servers; |
aviau | 922473c | 2016-12-12 17:49:55 -0500 | [diff] [blame] | 82 | GtkWidget *treeview_bootstrap_servers; |
aviau | 5d3e40a | 2016-12-12 15:33:10 -0500 | [diff] [blame] | 83 | GtkWidget *frame_video_codecs; |
| 84 | GtkWidget *frame_audio_codecs; |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 85 | |
| 86 | QMetaObject::Connection account_updated; |
| 87 | }; |
| 88 | |
| 89 | G_DEFINE_TYPE_WITH_PRIVATE(AccountAdvancedTab, account_advanced_tab, GTK_TYPE_BOX); |
| 90 | |
| 91 | #define ACCOUNT_ADVANCED_TAB_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ACCOUNT_ADVANCED_TAB_TYPE, AccountAdvancedTabPrivate)) |
| 92 | |
| 93 | static void |
| 94 | account_advanced_tab_dispose(GObject *object) |
| 95 | { |
| 96 | AccountAdvancedTab *view = ACCOUNT_ADVANCED_TAB(object); |
| 97 | AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(view); |
| 98 | |
| 99 | QObject::disconnect(priv->account_updated); |
| 100 | |
| 101 | G_OBJECT_CLASS(account_advanced_tab_parent_class)->dispose(object); |
| 102 | } |
| 103 | |
| 104 | static void |
| 105 | account_advanced_tab_init(AccountAdvancedTab *view) |
| 106 | { |
| 107 | gtk_widget_init_template(GTK_WIDGET(view)); |
| 108 | } |
| 109 | |
| 110 | static void |
| 111 | account_advanced_tab_class_init(AccountAdvancedTabClass *klass) |
| 112 | { |
| 113 | G_OBJECT_CLASS(klass)->dispose = account_advanced_tab_dispose; |
| 114 | |
| 115 | gtk_widget_class_set_template_from_resource(GTK_WIDGET_CLASS (klass), |
| 116 | "/cx/ring/RingGnome/accountadvancedtab.ui"); |
| 117 | |
| 118 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, vbox_main); |
| 119 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, frame_registration); |
Stepan Salenikovich | 2371a89 | 2015-07-23 17:17:00 -0400 | [diff] [blame] | 120 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, box_registration); |
| 121 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, box_registration_expire); |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 122 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, adjustment_registration_timeout); |
Stepan Salenikovich | 2371a89 | 2015-07-23 17:17:00 -0400 | [diff] [blame] | 123 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, checkbutton_allow_incoming_unknown); |
| 124 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, checkbutton_allow_incoming_history); |
| 125 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, checkbutton_allow_incoming_contacts); |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 126 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, frame_network_interface); |
| 127 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, box_network_interface); |
| 128 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, checkbutton_use_random_port); |
| 129 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, box_local_port); |
| 130 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, adjustment_local_port); |
| 131 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, radiobutton_same_as_local); |
| 132 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, radiobutton_set_published); |
| 133 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, box_published_address_port); |
| 134 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, entry_published_address); |
| 135 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, spinbutton_published_port); |
| 136 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, adjustment_published_port); |
| 137 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, checkbutton_use_stun); |
Stepan Salenikovich | 28c1f0c | 2015-08-06 11:42:41 -0400 | [diff] [blame] | 138 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, grid_stun); |
| 139 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, entry_stunserver); |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 140 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, checkbutton_use_turn); |
Stepan Salenikovich | 28c1f0c | 2015-08-06 11:42:41 -0400 | [diff] [blame] | 141 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, grid_turn); |
| 142 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, entry_turnserver); |
| 143 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, entry_turnusername); |
| 144 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, entry_turnpassword); |
| 145 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, entry_turnrealm); |
aviau | cbb2fc4 | 2016-12-12 15:55:24 -0500 | [diff] [blame] | 146 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, frame_ice_fallback); |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 147 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, adjustment_audio_port_min); |
| 148 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, adjustment_audio_port_max); |
| 149 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, adjustment_video_port_min); |
| 150 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, adjustment_video_port_max); |
aviau | 922473c | 2016-12-12 17:49:55 -0500 | [diff] [blame] | 151 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, box_bootstrap_servers); |
aviau | 5d3e40a | 2016-12-12 15:33:10 -0500 | [diff] [blame] | 152 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, frame_bootstrap_servers); |
| 153 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, frame_audio_codecs); |
| 154 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, frame_video_codecs); |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | static void |
| 158 | registration_expire_changed(GtkAdjustment *adjustment, AccountAdvancedTab *self) |
| 159 | { |
| 160 | g_return_if_fail(IS_ACCOUNT_ADVANCED_TAB(self)); |
| 161 | AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(self); |
| 162 | |
| 163 | int timeout = (int)gtk_adjustment_get_value(GTK_ADJUSTMENT(adjustment)); |
| 164 | priv->account->setRegistrationExpire(timeout); |
| 165 | } |
| 166 | |
| 167 | static void |
| 168 | local_port_changed(GtkAdjustment *adjustment, AccountAdvancedTab *self) |
| 169 | { |
| 170 | g_return_if_fail(IS_ACCOUNT_ADVANCED_TAB(self)); |
| 171 | AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(self); |
| 172 | |
| 173 | unsigned short int local_port = (unsigned short int)gtk_adjustment_get_value(GTK_ADJUSTMENT(adjustment)); |
| 174 | |
| 175 | if (priv->account->protocol() != Account::Protocol::RING) { |
| 176 | priv->account->setLocalPort(local_port); |
| 177 | } else { |
| 178 | priv->account->setBootstrapPort(local_port); |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | static void |
| 183 | same_as_local_toggled(GtkToggleButton *toggle_button, AccountAdvancedTab *self) |
| 184 | { |
| 185 | g_return_if_fail(IS_ACCOUNT_ADVANCED_TAB(self)); |
| 186 | AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(self); |
| 187 | |
| 188 | gboolean published_same_as_local = gtk_toggle_button_get_active(toggle_button); |
| 189 | |
| 190 | priv->account->setPublishedSameAsLocal(published_same_as_local); |
| 191 | |
| 192 | /* disactivate the published address and port fields if same as local is true */ |
| 193 | gtk_widget_set_sensitive(priv->box_published_address_port, !published_same_as_local); |
| 194 | } |
| 195 | |
| 196 | static void |
| 197 | published_address_changed(GtkEntry *entry, AccountAdvancedTab *self) |
| 198 | { |
| 199 | g_return_if_fail(IS_ACCOUNT_ADVANCED_TAB(self)); |
| 200 | AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(self); |
| 201 | |
| 202 | priv->account->setPublishedAddress(gtk_entry_get_text(entry)); |
| 203 | } |
| 204 | |
| 205 | static void |
| 206 | published_port_changed(GtkAdjustment *adjustment, AccountAdvancedTab *self) |
| 207 | { |
| 208 | g_return_if_fail(IS_ACCOUNT_ADVANCED_TAB(self)); |
| 209 | AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(self); |
| 210 | |
| 211 | unsigned short int published_port = (unsigned short int)gtk_adjustment_get_value(GTK_ADJUSTMENT(adjustment)); |
| 212 | priv->account->setPublishedPort(published_port); |
| 213 | } |
| 214 | |
| 215 | static void |
| 216 | stun_enabled_toggled(GtkToggleButton *toggle_button, AccountAdvancedTab *self) |
| 217 | { |
| 218 | g_return_if_fail(IS_ACCOUNT_ADVANCED_TAB(self)); |
| 219 | AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(self); |
| 220 | |
| 221 | gboolean use_stun = gtk_toggle_button_get_active(toggle_button); |
| 222 | |
| 223 | priv->account->setSipStunEnabled(use_stun); |
| 224 | |
| 225 | /* disactivate the stun server entry if stun is disabled */ |
Stepan Salenikovich | 28c1f0c | 2015-08-06 11:42:41 -0400 | [diff] [blame] | 226 | gtk_widget_set_sensitive(priv->grid_stun, use_stun); |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 227 | } |
| 228 | |
| 229 | static void |
| 230 | stun_server_changed(GtkEntry *entry, AccountAdvancedTab *self) |
| 231 | { |
| 232 | g_return_if_fail(IS_ACCOUNT_ADVANCED_TAB(self)); |
| 233 | AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(self); |
| 234 | |
| 235 | priv->account->setSipStunServer(gtk_entry_get_text(entry)); |
| 236 | } |
| 237 | |
| 238 | static void |
| 239 | turn_enabled_toggled(GtkToggleButton *toggle_button, AccountAdvancedTab *self) |
| 240 | { |
| 241 | g_return_if_fail(IS_ACCOUNT_ADVANCED_TAB(self)); |
| 242 | AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(self); |
| 243 | |
| 244 | gboolean use_turn = gtk_toggle_button_get_active(toggle_button); |
| 245 | |
| 246 | priv->account->setTurnEnabled(use_turn); |
| 247 | |
| 248 | /* disactivate the turn server entry if turn is disabled */ |
Stepan Salenikovich | 28c1f0c | 2015-08-06 11:42:41 -0400 | [diff] [blame] | 249 | gtk_widget_set_sensitive(priv->grid_turn, use_turn); |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | static void |
| 253 | turn_server_changed(GtkEntry *entry, AccountAdvancedTab *self) |
| 254 | { |
| 255 | g_return_if_fail(IS_ACCOUNT_ADVANCED_TAB(self)); |
| 256 | AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(self); |
| 257 | |
| 258 | priv->account->setTurnServer(gtk_entry_get_text(entry)); |
| 259 | } |
| 260 | |
| 261 | static void |
Stepan Salenikovich | 28c1f0c | 2015-08-06 11:42:41 -0400 | [diff] [blame] | 262 | turn_serverusername_changed(GtkEntry *entry, AccountAdvancedTab *self) |
| 263 | { |
| 264 | g_return_if_fail(IS_ACCOUNT_ADVANCED_TAB(self)); |
| 265 | AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(self); |
| 266 | |
| 267 | priv->account->setTurnServerUsername(gtk_entry_get_text(entry)); |
| 268 | } |
| 269 | |
| 270 | static void |
| 271 | turn_serverpassword_changed(GtkEntry *entry, AccountAdvancedTab *self) |
| 272 | { |
| 273 | g_return_if_fail(IS_ACCOUNT_ADVANCED_TAB(self)); |
| 274 | AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(self); |
| 275 | |
| 276 | priv->account->setTurnServerPassword(gtk_entry_get_text(entry)); |
| 277 | } |
| 278 | |
| 279 | static void |
| 280 | turn_serverrealm_changed(GtkEntry *entry, AccountAdvancedTab *self) |
| 281 | { |
| 282 | g_return_if_fail(IS_ACCOUNT_ADVANCED_TAB(self)); |
| 283 | AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(self); |
| 284 | |
| 285 | priv->account->setTurnServerRealm(gtk_entry_get_text(entry)); |
| 286 | } |
| 287 | |
| 288 | static void |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 289 | audio_port_min_changed(GtkAdjustment *adjustment, AccountAdvancedTab *self) |
| 290 | { |
| 291 | g_return_if_fail(IS_ACCOUNT_ADVANCED_TAB(self)); |
| 292 | AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(self); |
| 293 | |
| 294 | int port = (int)gtk_adjustment_get_value(GTK_ADJUSTMENT(adjustment)); |
| 295 | priv->account->setAudioPortMin(port); |
| 296 | } |
| 297 | |
| 298 | static void |
| 299 | audio_port_max_changed(GtkAdjustment *adjustment, AccountAdvancedTab *self) |
| 300 | { |
| 301 | g_return_if_fail(IS_ACCOUNT_ADVANCED_TAB(self)); |
| 302 | AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(self); |
| 303 | |
| 304 | int port = (int)gtk_adjustment_get_value(GTK_ADJUSTMENT(adjustment)); |
| 305 | priv->account->setAudioPortMax(port); |
| 306 | } |
| 307 | |
| 308 | static void |
| 309 | video_port_min_changed(GtkAdjustment *adjustment, AccountAdvancedTab *self) |
| 310 | { |
| 311 | g_return_if_fail(IS_ACCOUNT_ADVANCED_TAB(self)); |
| 312 | AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(self); |
| 313 | |
| 314 | int port = (int)gtk_adjustment_get_value(GTK_ADJUSTMENT(adjustment)); |
| 315 | priv->account->setVideoPortMin(port); |
| 316 | } |
| 317 | |
| 318 | static void |
| 319 | video_port_max_changed(GtkAdjustment *adjustment, AccountAdvancedTab *self) |
| 320 | { |
| 321 | g_return_if_fail(IS_ACCOUNT_ADVANCED_TAB(self)); |
| 322 | AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(self); |
| 323 | |
| 324 | int port = (int)gtk_adjustment_get_value(GTK_ADJUSTMENT(adjustment)); |
| 325 | priv->account->setVideoPortMax(port); |
| 326 | } |
| 327 | |
| 328 | static void |
Stepan Salenikovich | 2371a89 | 2015-07-23 17:17:00 -0400 | [diff] [blame] | 329 | allow_from_unknown_toggled(GtkToggleButton *toggle_button, AccountAdvancedTab *self) |
| 330 | { |
| 331 | g_return_if_fail(IS_ACCOUNT_ADVANCED_TAB(self)); |
| 332 | AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(self); |
| 333 | |
| 334 | gboolean allow = gtk_toggle_button_get_active(toggle_button); |
| 335 | |
| 336 | priv->account->setAllowIncomingFromUnknown(allow); |
| 337 | } |
| 338 | |
| 339 | static void |
| 340 | allow_from_history_toggled(GtkToggleButton *toggle_button, AccountAdvancedTab *self) |
| 341 | { |
| 342 | g_return_if_fail(IS_ACCOUNT_ADVANCED_TAB(self)); |
| 343 | AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(self); |
| 344 | |
| 345 | gboolean allow = gtk_toggle_button_get_active(toggle_button); |
| 346 | |
| 347 | priv->account->setAllowIncomingFromHistory(allow); |
| 348 | } |
| 349 | |
| 350 | static void |
| 351 | allow_from_contacts_toggled(GtkToggleButton *toggle_button, AccountAdvancedTab *self) |
| 352 | { |
| 353 | g_return_if_fail(IS_ACCOUNT_ADVANCED_TAB(self)); |
| 354 | AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(self); |
| 355 | |
| 356 | gboolean allow = gtk_toggle_button_get_active(toggle_button); |
| 357 | |
| 358 | priv->account->setAllowIncomingFromContact(allow); |
| 359 | } |
| 360 | |
| 361 | static void |
aviau | 922473c | 2016-12-12 17:49:55 -0500 | [diff] [blame] | 362 | remove_bootstrap_server(GtkWidget *item, AccountAdvancedTab *view) |
| 363 | { |
| 364 | g_return_if_fail(IS_ACCOUNT_ADVANCED_TAB(view)); |
| 365 | AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(view); |
| 366 | auto row = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(item), "bootstrap-server-row")); |
| 367 | priv->account->bootstrapModel()->removeRows(row, 1); |
| 368 | } |
| 369 | |
| 370 | static gboolean |
| 371 | bootstrap_servers_popup_menu(G_GNUC_UNUSED GtkWidget *widget, GdkEventButton *event, AccountAdvancedTab *view) |
| 372 | { |
| 373 | g_return_val_if_fail(IS_ACCOUNT_ADVANCED_TAB(view), FALSE); |
| 374 | AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(view); |
| 375 | |
| 376 | /* check for right click */ |
| 377 | if (event->button != BUTTON_RIGHT_CLICK || event->type != GDK_BUTTON_PRESS) |
| 378 | return FALSE; |
| 379 | |
| 380 | GtkTreeIter iter; |
| 381 | GtkTreeModel *model; |
| 382 | GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview_bootstrap_servers)); |
| 383 | if (!gtk_tree_selection_get_selected(selection, &model, &iter)) |
| 384 | return FALSE; |
| 385 | |
| 386 | GtkWidget *menu = gtk_menu_new(); |
| 387 | QModelIndex idx = get_index_from_selection(selection); |
| 388 | |
| 389 | GtkWidget *remove_server_item = gtk_menu_item_new_with_mnemonic(_("_Remove server")); |
| 390 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), remove_server_item); |
| 391 | g_object_set_data(G_OBJECT(remove_server_item), "bootstrap-server-row", GUINT_TO_POINTER(idx.row())); |
| 392 | g_signal_connect(remove_server_item, |
| 393 | "activate", |
| 394 | G_CALLBACK(remove_bootstrap_server), |
| 395 | view); |
| 396 | |
| 397 | /* show menu */ |
| 398 | gtk_widget_show_all(menu); |
| 399 | gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, event->button, event->time); |
| 400 | |
| 401 | return TRUE; /* we handled the event */ |
| 402 | } |
| 403 | |
| 404 | static void |
| 405 | bootstrap_server_edited(GtkCellRendererText *renderer, gchar *path, gchar *new_text, AccountAdvancedTab *view) |
| 406 | { |
| 407 | g_return_if_fail(IS_ACCOUNT_ADVANCED_TAB(view)); |
| 408 | AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(view); |
| 409 | |
| 410 | /* get iter which was clicked */ |
| 411 | GtkTreePath *tree_path = gtk_tree_path_new_from_string(path); |
| 412 | GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(priv->treeview_bootstrap_servers)); |
| 413 | GtkTreeIter iter; |
| 414 | gtk_tree_model_get_iter(model, &iter, tree_path); |
| 415 | |
| 416 | /* get qmodelindex from iter and set the model data */ |
| 417 | auto column = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(renderer), "model-column")); |
| 418 | QModelIndex idx = gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(model), &iter); |
| 419 | if (idx.isValid()) { |
| 420 | priv->account->bootstrapModel()->setData( |
| 421 | idx.sibling(idx.row(), column), |
| 422 | QVariant(new_text), |
| 423 | Qt::EditRole |
| 424 | ); |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | static void |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 429 | build_tab_view(AccountAdvancedTab *self) |
| 430 | { |
| 431 | g_return_if_fail(IS_ACCOUNT_ADVANCED_TAB(self)); |
| 432 | AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(self); |
| 433 | |
Stepan Salenikovich | fea8405 | 2016-05-13 16:32:51 -0400 | [diff] [blame] | 434 | /* only show registration timeout for SIP account */ |
| 435 | if (priv->account->protocol() != Account::Protocol::SIP) { |
| 436 | gtk_container_remove(GTK_CONTAINER(priv->box_registration), priv->box_registration_expire); |
Stepan Salenikovich | 2371a89 | 2015-07-23 17:17:00 -0400 | [diff] [blame] | 437 | priv->box_registration_expire = NULL; |
Stepan Salenikovich | fea8405 | 2016-05-13 16:32:51 -0400 | [diff] [blame] | 438 | } else { |
| 439 | gtk_adjustment_set_value(GTK_ADJUSTMENT(priv->adjustment_registration_timeout), |
| 440 | priv->account->registrationExpire()); |
| 441 | g_signal_connect(priv->adjustment_registration_timeout, |
| 442 | "value-changed", G_CALLBACK(registration_expire_changed), self); |
| 443 | } |
| 444 | |
| 445 | /* only show allow call options for Ring accounts */ |
| 446 | if (priv->account->protocol() != Account::Protocol::RING) { |
| 447 | gtk_container_remove(GTK_CONTAINER(priv->box_registration), priv->checkbutton_allow_incoming_unknown); |
Stepan Salenikovich | 2371a89 | 2015-07-23 17:17:00 -0400 | [diff] [blame] | 448 | priv->checkbutton_allow_incoming_unknown = NULL; |
Stepan Salenikovich | fea8405 | 2016-05-13 16:32:51 -0400 | [diff] [blame] | 449 | gtk_container_remove(GTK_CONTAINER(priv->box_registration), priv->checkbutton_allow_incoming_history); |
Stepan Salenikovich | 2371a89 | 2015-07-23 17:17:00 -0400 | [diff] [blame] | 450 | priv->checkbutton_allow_incoming_history = NULL; |
Stepan Salenikovich | fea8405 | 2016-05-13 16:32:51 -0400 | [diff] [blame] | 451 | gtk_container_remove(GTK_CONTAINER(priv->box_registration), priv->checkbutton_allow_incoming_contacts); |
Stepan Salenikovich | 2371a89 | 2015-07-23 17:17:00 -0400 | [diff] [blame] | 452 | priv->checkbutton_allow_incoming_contacts = NULL; |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 453 | } else { |
Stepan Salenikovich | fea8405 | 2016-05-13 16:32:51 -0400 | [diff] [blame] | 454 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->checkbutton_allow_incoming_unknown), |
| 455 | priv->account->allowIncomingFromUnknown()); |
| 456 | g_signal_connect(priv->checkbutton_allow_incoming_unknown, |
| 457 | "toggled", G_CALLBACK(allow_from_unknown_toggled), self); |
| 458 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->checkbutton_allow_incoming_history), |
| 459 | priv->account->allowIncomingFromHistory()); |
| 460 | g_signal_connect(priv->checkbutton_allow_incoming_history, |
| 461 | "toggled", G_CALLBACK(allow_from_history_toggled), self); |
| 462 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->checkbutton_allow_incoming_contacts), |
| 463 | priv->account->allowIncomingFromContact()); |
| 464 | g_signal_connect(priv->checkbutton_allow_incoming_contacts, |
| 465 | "toggled", G_CALLBACK(allow_from_contacts_toggled), self); |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 466 | } |
| 467 | |
aviau | 922473c | 2016-12-12 17:49:55 -0500 | [diff] [blame] | 468 | /* bootstrap servers */ |
| 469 | if (priv->account->protocol() == Account::Protocol::RING) { |
| 470 | |
| 471 | priv->treeview_bootstrap_servers = gtk_tree_view_new(); |
| 472 | gtk_widget_show(priv->treeview_bootstrap_servers); |
| 473 | g_signal_connect(GTK_WIDGET(priv->treeview_bootstrap_servers), |
| 474 | "button-press-event", |
| 475 | G_CALLBACK(bootstrap_servers_popup_menu), |
| 476 | GTK_WIDGET(self)); |
| 477 | |
| 478 | auto bootstrap_servers_frame = gtk_frame_new(NULL); |
| 479 | gtk_widget_show(bootstrap_servers_frame); |
| 480 | gtk_container_add(GTK_CONTAINER(bootstrap_servers_frame), GTK_WIDGET(priv->treeview_bootstrap_servers)); |
| 481 | |
| 482 | auto bootstrap_servers_scrolled_window = gtk_scrolled_window_new(NULL, NULL); |
| 483 | gtk_widget_show(bootstrap_servers_scrolled_window); |
| 484 | gtk_widget_set_halign(bootstrap_servers_scrolled_window, GTK_ALIGN_START); |
| 485 | gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(bootstrap_servers_scrolled_window), 100); |
| 486 | gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(bootstrap_servers_scrolled_window), 400); |
| 487 | gtk_container_add(GTK_CONTAINER(bootstrap_servers_scrolled_window), bootstrap_servers_frame); |
| 488 | |
| 489 | auto *bootstrap_model = gtk_q_tree_model_new( |
| 490 | (QAbstractItemModel*) priv->account->bootstrapModel(), |
| 491 | 2, |
| 492 | BootstrapModel::Columns::HOSTNAME, Qt::DisplayRole, G_TYPE_STRING, |
| 493 | BootstrapModel::Columns::PORT, Qt::DisplayRole, G_TYPE_STRING); |
| 494 | |
| 495 | gtk_tree_view_set_model(GTK_TREE_VIEW(priv->treeview_bootstrap_servers), GTK_TREE_MODEL(bootstrap_model)); |
| 496 | |
| 497 | GtkCellRenderer *renderer; |
| 498 | GtkTreeViewColumn *column; |
| 499 | |
| 500 | renderer = gtk_cell_renderer_text_new(); |
| 501 | g_object_set(renderer, "editable", true, NULL); |
| 502 | column = gtk_tree_view_column_new_with_attributes(_("Hostname"), renderer, "text", 0, NULL); |
| 503 | gtk_tree_view_column_set_expand(column, TRUE); |
| 504 | gtk_tree_view_append_column(GTK_TREE_VIEW(priv->treeview_bootstrap_servers), column); |
| 505 | g_object_set_data(G_OBJECT(renderer), "model-column", GUINT_TO_POINTER(BootstrapModel::Columns::HOSTNAME)); |
| 506 | g_signal_connect(renderer, "edited", G_CALLBACK(bootstrap_server_edited), self); |
| 507 | |
| 508 | renderer = gtk_cell_renderer_text_new(); |
| 509 | g_object_set(renderer, "editable", true, NULL); |
| 510 | column = gtk_tree_view_column_new_with_attributes(_("Port"), renderer, "text", 1, NULL); |
| 511 | gtk_tree_view_column_set_expand(column, TRUE); |
| 512 | gtk_tree_view_append_column(GTK_TREE_VIEW(priv->treeview_bootstrap_servers), column); |
| 513 | g_object_set_data(G_OBJECT(renderer), "model-column", GUINT_TO_POINTER(BootstrapModel::Columns::PORT)); |
| 514 | g_signal_connect(renderer, "edited", G_CALLBACK(bootstrap_server_edited), self); |
| 515 | |
| 516 | gtk_container_add( |
| 517 | GTK_CONTAINER(priv->box_bootstrap_servers), |
| 518 | bootstrap_servers_scrolled_window |
| 519 | ); |
| 520 | |
| 521 | } |
| 522 | else { |
aviau | 5d3e40a | 2016-12-12 15:33:10 -0500 | [diff] [blame] | 523 | gtk_widget_hide(priv->frame_bootstrap_servers); |
aviau | 922473c | 2016-12-12 17:49:55 -0500 | [diff] [blame] | 524 | } |
| 525 | |
| 526 | |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 527 | /* local port */ |
| 528 | if (priv->account->protocol() != Account::Protocol::RING) { |
| 529 | gtk_container_remove(GTK_CONTAINER(priv->box_network_interface), priv->checkbutton_use_random_port); |
| 530 | priv->checkbutton_use_random_port = NULL; |
| 531 | gtk_adjustment_set_value(GTK_ADJUSTMENT(priv->adjustment_local_port), |
| 532 | priv->account->localPort()); |
| 533 | g_signal_connect(priv->adjustment_local_port, |
| 534 | "value-changed", G_CALLBACK(local_port_changed), self); |
| 535 | } else { |
| 536 | /* TODO: when this option is added, for now just don't set it |
| 537 | * gtk_adjustment_set_value(GTK_ADJUSTMENT(priv->adjustment_local_port), |
| 538 | * priv->account->bootstrapPort()); |
| 539 | */ |
| 540 | gtk_container_remove(GTK_CONTAINER(priv->vbox_main), priv->frame_network_interface); |
| 541 | priv->frame_network_interface = NULL; |
| 542 | } |
| 543 | |
| 544 | /* published address/port same as local */ |
| 545 | if (priv->account->isPublishedSameAsLocal()) { |
| 546 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->radiobutton_same_as_local), TRUE); |
| 547 | |
| 548 | /* disactivate the published address and port fields if same as local is true */ |
| 549 | gtk_widget_set_sensitive(priv->box_published_address_port, FALSE); |
| 550 | } else { |
| 551 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->radiobutton_set_published), TRUE); |
| 552 | } |
| 553 | |
| 554 | g_signal_connect(priv->radiobutton_same_as_local, |
| 555 | "toggled", G_CALLBACK(same_as_local_toggled), self); |
| 556 | |
| 557 | /* published address and port */ |
| 558 | gtk_entry_set_text(GTK_ENTRY(priv->entry_published_address), |
| 559 | priv->account->publishedAddress().toUtf8().constData()); |
| 560 | g_signal_connect(priv->entry_published_address, |
| 561 | "changed", G_CALLBACK(published_address_changed), self); |
| 562 | |
| 563 | gtk_adjustment_set_value(GTK_ADJUSTMENT(priv->adjustment_published_port), |
| 564 | priv->account->publishedPort()); |
| 565 | g_signal_connect(priv->adjustment_published_port, |
| 566 | "value-changed", G_CALLBACK(published_port_changed), self); |
| 567 | |
| 568 | /* STUN */ |
| 569 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->checkbutton_use_stun), |
| 570 | priv->account->isSipStunEnabled()); |
Stepan Salenikovich | 28c1f0c | 2015-08-06 11:42:41 -0400 | [diff] [blame] | 571 | gtk_entry_set_text(GTK_ENTRY(priv->entry_stunserver), |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 572 | priv->account->sipStunServer().toUtf8().constData()); |
Stepan Salenikovich | 28c1f0c | 2015-08-06 11:42:41 -0400 | [diff] [blame] | 573 | gtk_widget_set_sensitive(priv->grid_stun, |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 574 | priv->account->isSipStunEnabled()); |
| 575 | g_signal_connect(priv->checkbutton_use_stun, |
| 576 | "toggled", G_CALLBACK(stun_enabled_toggled), self); |
Stepan Salenikovich | 28c1f0c | 2015-08-06 11:42:41 -0400 | [diff] [blame] | 577 | g_signal_connect(priv->entry_stunserver, |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 578 | "changed", G_CALLBACK(stun_server_changed), self); |
| 579 | |
| 580 | /* TURN */ |
| 581 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->checkbutton_use_turn), |
| 582 | priv->account->isTurnEnabled()); |
Stepan Salenikovich | 28c1f0c | 2015-08-06 11:42:41 -0400 | [diff] [blame] | 583 | gtk_entry_set_text(GTK_ENTRY(priv->entry_turnserver), |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 584 | priv->account->turnServer().toUtf8().constData()); |
Stepan Salenikovich | 28c1f0c | 2015-08-06 11:42:41 -0400 | [diff] [blame] | 585 | gtk_entry_set_text(GTK_ENTRY(priv->entry_turnusername), |
| 586 | priv->account->turnServerUsername().toUtf8().constData()); |
| 587 | gtk_entry_set_text(GTK_ENTRY(priv->entry_turnpassword), |
| 588 | priv->account->turnServerPassword().toUtf8().constData()); |
| 589 | gtk_entry_set_text(GTK_ENTRY(priv->entry_turnrealm), |
| 590 | priv->account->turnServerRealm().toUtf8().constData()); |
| 591 | gtk_widget_set_sensitive(priv->grid_turn, |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 592 | priv->account->isTurnEnabled()); |
| 593 | g_signal_connect(priv->checkbutton_use_turn, |
| 594 | "toggled", G_CALLBACK(turn_enabled_toggled), self); |
Stepan Salenikovich | 28c1f0c | 2015-08-06 11:42:41 -0400 | [diff] [blame] | 595 | g_signal_connect(priv->entry_turnserver, |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 596 | "changed", G_CALLBACK(turn_server_changed), self); |
Stepan Salenikovich | 28c1f0c | 2015-08-06 11:42:41 -0400 | [diff] [blame] | 597 | g_signal_connect(priv->entry_turnusername, |
| 598 | "changed", G_CALLBACK(turn_serverusername_changed), self); |
| 599 | g_signal_connect(priv->entry_turnpassword, |
| 600 | "changed", G_CALLBACK(turn_serverpassword_changed), self); |
| 601 | g_signal_connect(priv->entry_turnrealm, |
| 602 | "changed", G_CALLBACK(turn_serverrealm_changed), self); |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 603 | |
| 604 | /* audio/video rtp port range */ |
aviau | cbb2fc4 | 2016-12-12 15:55:24 -0500 | [diff] [blame] | 605 | |
| 606 | /* ice fallback features are not relevant to Ring account, as every RING |
| 607 | client supports ICE */ |
| 608 | gtk_widget_set_visible( |
| 609 | priv->frame_ice_fallback, |
| 610 | priv->account->protocol() != Account::Protocol::RING |
| 611 | ); |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 612 | gtk_adjustment_set_value(GTK_ADJUSTMENT(priv->adjustment_audio_port_min), |
| 613 | priv->account->audioPortMin()); |
| 614 | g_signal_connect(priv->adjustment_audio_port_min, |
| 615 | "value-changed", G_CALLBACK(audio_port_min_changed), self); |
| 616 | gtk_adjustment_set_value(GTK_ADJUSTMENT(priv->adjustment_audio_port_max), |
| 617 | priv->account->audioPortMax()); |
| 618 | g_signal_connect(priv->adjustment_audio_port_min, |
| 619 | "value-changed", G_CALLBACK(audio_port_max_changed), self); |
| 620 | gtk_adjustment_set_value(GTK_ADJUSTMENT(priv->adjustment_video_port_min), |
| 621 | priv->account->videoPortMin()); |
| 622 | g_signal_connect(priv->adjustment_audio_port_min, |
| 623 | "value-changed", G_CALLBACK(video_port_min_changed), self); |
| 624 | gtk_adjustment_set_value(GTK_ADJUSTMENT(priv->adjustment_video_port_max), |
| 625 | priv->account->videoPortMax()); |
| 626 | g_signal_connect(priv->adjustment_video_port_max, |
| 627 | "value-changed", G_CALLBACK(video_port_max_changed), self); |
| 628 | |
aviau | 5d3e40a | 2016-12-12 15:33:10 -0500 | [diff] [blame] | 629 | /* audio and video codecs */ |
| 630 | auto video_codecs = account_video_tab_new(priv->account); |
| 631 | gtk_container_add( |
| 632 | GTK_CONTAINER(priv->frame_video_codecs), |
| 633 | video_codecs |
| 634 | ); |
| 635 | gtk_widget_show(video_codecs); |
| 636 | |
| 637 | auto audio_codecs = account_audio_tab_new(priv->account); |
| 638 | gtk_container_add( |
| 639 | GTK_CONTAINER(priv->frame_audio_codecs), |
| 640 | audio_codecs |
| 641 | ); |
| 642 | gtk_widget_show(audio_codecs); |
| 643 | |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 644 | /* update account UI if model is updated */ |
| 645 | priv->account_updated = QObject::connect( |
| 646 | priv->account, |
| 647 | &Account::changed, |
| 648 | [=] () { |
| 649 | /* only show registration timeout for SIP account */ |
Stepan Salenikovich | 2371a89 | 2015-07-23 17:17:00 -0400 | [diff] [blame] | 650 | if ( priv->box_registration_expire ) { |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 651 | gtk_adjustment_set_value(GTK_ADJUSTMENT(priv->adjustment_registration_timeout), |
| 652 | priv->account->registrationExpire()); |
| 653 | } |
| 654 | |
Stepan Salenikovich | 2371a89 | 2015-07-23 17:17:00 -0400 | [diff] [blame] | 655 | if (priv->checkbutton_allow_incoming_unknown) |
| 656 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->checkbutton_allow_incoming_unknown), |
| 657 | priv->account->allowIncomingFromUnknown()); |
| 658 | |
| 659 | if (priv->checkbutton_allow_incoming_history) |
| 660 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->checkbutton_allow_incoming_history), |
| 661 | priv->account->allowIncomingFromHistory()); |
| 662 | |
| 663 | if (priv->checkbutton_allow_incoming_contacts) |
| 664 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->checkbutton_allow_incoming_contacts), |
| 665 | priv->account->allowIncomingFromContact()); |
| 666 | |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 667 | /* local port */ |
| 668 | if (priv->account->protocol() != Account::Protocol::RING) { |
| 669 | gtk_adjustment_set_value(GTK_ADJUSTMENT(priv->adjustment_local_port), |
| 670 | priv->account->localPort()); |
| 671 | } |
| 672 | |
| 673 | /* published address/port same as local */ |
| 674 | if (priv->account->isPublishedSameAsLocal()) { |
| 675 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->radiobutton_same_as_local), TRUE); |
| 676 | } else { |
| 677 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->radiobutton_set_published), TRUE); |
| 678 | } |
| 679 | |
| 680 | /* published address and port */ |
| 681 | gtk_entry_set_text(GTK_ENTRY(priv->entry_published_address), |
| 682 | priv->account->publishedAddress().toUtf8().constData()); |
| 683 | gtk_adjustment_set_value(GTK_ADJUSTMENT(priv->adjustment_published_port), |
| 684 | priv->account->publishedPort()); |
| 685 | |
| 686 | /* STUN */ |
| 687 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->checkbutton_use_stun), |
| 688 | priv->account->isSipStunEnabled()); |
Stepan Salenikovich | 28c1f0c | 2015-08-06 11:42:41 -0400 | [diff] [blame] | 689 | gtk_widget_set_sensitive(priv->grid_stun, priv->account->isSipStunEnabled()); |
| 690 | gtk_entry_set_text(GTK_ENTRY(priv->entry_stunserver), |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 691 | priv->account->sipStunServer().toUtf8().constData()); |
| 692 | |
| 693 | /* TURN */ |
| 694 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->checkbutton_use_turn), |
| 695 | priv->account->isTurnEnabled()); |
Stepan Salenikovich | 28c1f0c | 2015-08-06 11:42:41 -0400 | [diff] [blame] | 696 | gtk_widget_set_sensitive(priv->grid_turn, priv->account->isTurnEnabled()); |
| 697 | gtk_entry_set_text(GTK_ENTRY(priv->entry_turnserver), |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 698 | priv->account->turnServer().toUtf8().constData()); |
Stepan Salenikovich | 28c1f0c | 2015-08-06 11:42:41 -0400 | [diff] [blame] | 699 | gtk_entry_set_text(GTK_ENTRY(priv->entry_turnusername), |
| 700 | priv->account->turnServerUsername().toUtf8().constData()); |
| 701 | gtk_entry_set_text(GTK_ENTRY(priv->entry_turnpassword), |
| 702 | priv->account->turnServerPassword().toUtf8().constData()); |
| 703 | gtk_entry_set_text(GTK_ENTRY(priv->entry_turnrealm), |
| 704 | priv->account->turnServerRealm().toUtf8().constData()); |
Stepan Salenikovich | b7e6a73 | 2015-05-04 17:13:22 -0400 | [diff] [blame] | 705 | |
| 706 | /* audio/video rtp port range */ |
| 707 | gtk_adjustment_set_value(GTK_ADJUSTMENT(priv->adjustment_audio_port_min), |
| 708 | priv->account->audioPortMin()); |
| 709 | gtk_adjustment_set_value(GTK_ADJUSTMENT(priv->adjustment_audio_port_max), |
| 710 | priv->account->audioPortMax()); |
| 711 | gtk_adjustment_set_value(GTK_ADJUSTMENT(priv->adjustment_video_port_min), |
| 712 | priv->account->videoPortMin()); |
| 713 | gtk_adjustment_set_value(GTK_ADJUSTMENT(priv->adjustment_video_port_max), |
| 714 | priv->account->videoPortMax()); |
| 715 | } |
| 716 | ); |
| 717 | } |
| 718 | |
| 719 | GtkWidget * |
| 720 | account_advanced_tab_new(Account *account) |
| 721 | { |
| 722 | g_return_val_if_fail(account != NULL, NULL); |
| 723 | |
| 724 | gpointer view = g_object_new(ACCOUNT_ADVANCED_TAB_TYPE, NULL); |
| 725 | |
| 726 | AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(view); |
| 727 | priv->account = account; |
| 728 | |
| 729 | build_tab_view(ACCOUNT_ADVANCED_TAB(view)); |
| 730 | |
| 731 | return (GtkWidget *)view; |
| 732 | } |