Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Enhanced the cohesion of the Account class by grouping related elements to specific classes [ TLS + Media] #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions src/accountadvancedtab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ local_port_changed(GtkAdjustment *adjustment, AccountAdvancedTab *self)
unsigned short int local_port = (unsigned short int)gtk_adjustment_get_value(GTK_ADJUSTMENT(adjustment));

if (priv->account->protocol() != Account::Protocol::RING) {
priv->account->setLocalPort(local_port);
priv->account->getAccountTLS()->setLocalPort(local_port);
} else {
priv->account->setBootstrapPort(local_port);
priv->account->getAccountTLS()->setBootstrapPort(local_port);
}
}

Expand Down Expand Up @@ -191,7 +191,7 @@ published_port_changed(GtkAdjustment *adjustment, AccountAdvancedTab *self)
AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(self);

unsigned short int published_port = (unsigned short int)gtk_adjustment_get_value(GTK_ADJUSTMENT(adjustment));
priv->account->setPublishedPort(published_port);
priv->account->getAccountTLS()->setPublishedPort(published_port);
}

static void
Expand Down Expand Up @@ -274,7 +274,7 @@ audio_port_min_changed(GtkAdjustment *adjustment, AccountAdvancedTab *self)
AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(self);

int port = (int)gtk_adjustment_get_value(GTK_ADJUSTMENT(adjustment));
priv->account->setAudioPortMin(port);
priv->account->getAccountMedia()->setAudioPortMin(port);
}

static void
Expand All @@ -284,7 +284,7 @@ audio_port_max_changed(GtkAdjustment *adjustment, AccountAdvancedTab *self)
AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(self);

int port = (int)gtk_adjustment_get_value(GTK_ADJUSTMENT(adjustment));
priv->account->setAudioPortMax(port);
priv->account->getAccountMedia()->setAudioPortMax(port);
}

static void
Expand All @@ -294,7 +294,7 @@ video_port_min_changed(GtkAdjustment *adjustment, AccountAdvancedTab *self)
AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(self);

int port = (int)gtk_adjustment_get_value(GTK_ADJUSTMENT(adjustment));
priv->account->setVideoPortMin(port);
priv->account->getAccountMedia()->setVideoPortMin(port);
}

static void
Expand All @@ -304,7 +304,7 @@ video_port_max_changed(GtkAdjustment *adjustment, AccountAdvancedTab *self)
AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(self);

int port = (int)gtk_adjustment_get_value(GTK_ADJUSTMENT(adjustment));
priv->account->setVideoPortMax(port);
priv->account->getAccountMedia()->setVideoPortMax(port);
}

static void
Expand Down Expand Up @@ -391,7 +391,7 @@ build_tab_view(AccountAdvancedTab *self)
} else {
/* TODO: when this option is added, for now just don't set it
* gtk_adjustment_set_value(GTK_ADJUSTMENT(priv->adjustment_local_port),
* priv->account->bootstrapPort());
* priv->account->getAccountTLS()->bootstrapPort());
*/
gtk_container_remove(GTK_CONTAINER(priv->vbox_main), priv->frame_network_interface);
priv->frame_network_interface = NULL;
Expand Down Expand Up @@ -459,19 +459,19 @@ build_tab_view(AccountAdvancedTab *self)

/* audio/video rtp port range */
gtk_adjustment_set_value(GTK_ADJUSTMENT(priv->adjustment_audio_port_min),
priv->account->audioPortMin());
priv->account->getAccountMedia()->audioPortMin());
g_signal_connect(priv->adjustment_audio_port_min,
"value-changed", G_CALLBACK(audio_port_min_changed), self);
gtk_adjustment_set_value(GTK_ADJUSTMENT(priv->adjustment_audio_port_max),
priv->account->audioPortMax());
priv->account->getAccountMedia()->audioPortMax());
g_signal_connect(priv->adjustment_audio_port_min,
"value-changed", G_CALLBACK(audio_port_max_changed), self);
gtk_adjustment_set_value(GTK_ADJUSTMENT(priv->adjustment_video_port_min),
priv->account->videoPortMin());
priv->account->getAccountMedia()->videoPortMin());
g_signal_connect(priv->adjustment_audio_port_min,
"value-changed", G_CALLBACK(video_port_min_changed), self);
gtk_adjustment_set_value(GTK_ADJUSTMENT(priv->adjustment_video_port_max),
priv->account->videoPortMax());
priv->account->getAccountMedia()->videoPortMax());
g_signal_connect(priv->adjustment_video_port_max,
"value-changed", G_CALLBACK(video_port_max_changed), self);

Expand Down Expand Up @@ -539,13 +539,13 @@ build_tab_view(AccountAdvancedTab *self)

/* audio/video rtp port range */
gtk_adjustment_set_value(GTK_ADJUSTMENT(priv->adjustment_audio_port_min),
priv->account->audioPortMin());
priv->account->getAccountMedia()->audioPortMin());
gtk_adjustment_set_value(GTK_ADJUSTMENT(priv->adjustment_audio_port_max),
priv->account->audioPortMax());
priv->account->getAccountMedia()->audioPortMax());
gtk_adjustment_set_value(GTK_ADJUSTMENT(priv->adjustment_video_port_min),
priv->account->videoPortMin());
priv->account->getAccountMedia()->videoPortMin());
gtk_adjustment_set_value(GTK_ADJUSTMENT(priv->adjustment_video_port_max),
priv->account->videoPortMax());
priv->account->getAccountMedia()->videoPortMax());
}
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/accountgeneraltab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ auto_answer(GtkToggleButton *checkbutton, AccountGeneralTab *view)
{
g_return_if_fail(IS_ACCOUNT_GENERAL_TAB(view));
AccountGeneralTabPrivate *priv = ACCOUNT_GENERAL_TAB_GET_PRIVATE(view);
priv->account->setAutoAnswer(gtk_toggle_button_get_active(checkbutton));
priv->account->getAccountTLS()->setAutoAnswer(gtk_toggle_button_get_active(checkbutton));
}

static void
Expand Down
80 changes: 40 additions & 40 deletions src/accountsecuritytab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,16 @@ use_tls_toggled(GtkToggleButton *toggle_button, AccountSecurityTab *self)

gboolean use_tls = gtk_toggle_button_get_active(toggle_button);

priv->account->setTlsEnabled(use_tls);
priv->account->getAccountTLS()->setTlsEnabled(use_tls);

/* disable the other tls options if no tls */
gtk_widget_set_sensitive(priv->grid_tls_settings_0, priv->account->isTlsEnabled());
gtk_widget_set_sensitive(priv->grid_tls_settings_1, priv->account->isTlsEnabled());
gtk_widget_set_sensitive(priv->buttonbox_cipher_list, priv->account->isTlsEnabled());
gtk_widget_set_sensitive(priv->treeview_cipher_list, priv->account->isTlsEnabled());
gtk_widget_set_sensitive(priv->checkbutton_verify_certs_server, priv->account->isTlsEnabled());
gtk_widget_set_sensitive(priv->checkbutton_verify_certs_client, priv->account->isTlsEnabled());
gtk_widget_set_sensitive(priv->checkbutton_require_incoming_tls_certs, priv->account->isTlsEnabled());
gtk_widget_set_sensitive(priv->grid_tls_settings_0, priv->account->getAccountTLS()->isTlsEnabled());
gtk_widget_set_sensitive(priv->grid_tls_settings_1, priv->account->getAccountTLS()->isTlsEnabled());
gtk_widget_set_sensitive(priv->buttonbox_cipher_list, priv->account->getAccountTLS()->isTlsEnabled());
gtk_widget_set_sensitive(priv->treeview_cipher_list, priv->account->getAccountTLS()->isTlsEnabled());
gtk_widget_set_sensitive(priv->checkbutton_verify_certs_server, priv->account->getAccountTLS()->isTlsEnabled());
gtk_widget_set_sensitive(priv->checkbutton_verify_certs_client, priv->account->getAccountTLS()->isTlsEnabled());
gtk_widget_set_sensitive(priv->checkbutton_require_incoming_tls_certs, priv->account->getAccountTLS()->isTlsEnabled());
}

static void
Expand All @@ -211,7 +211,7 @@ tls_server_name_changed(GtkEntry *entry, AccountSecurityTab *self)
g_return_if_fail(IS_ACCOUNT_SECURITY_TAB(self));
AccountSecurityTabPrivate *priv = ACCOUNT_SECURITY_TAB_GET_PRIVATE(self);

priv->account->setTlsServerName(gtk_entry_get_text(entry));
priv->account->getAccountTLS()->setTlsServerName(gtk_entry_get_text(entry));
}

static void
Expand All @@ -221,7 +221,7 @@ tls_timeout_changed(GtkAdjustment *adjustment, AccountSecurityTab *self)
AccountSecurityTabPrivate *priv = ACCOUNT_SECURITY_TAB_GET_PRIVATE(self);

int timeout = (int)gtk_adjustment_get_value(GTK_ADJUSTMENT(adjustment));
priv->account->setTlsNegotiationTimeoutSec(timeout);
priv->account->getAccountTLS()->setTlsNegotiationTimeoutSec(timeout);
}

static void
Expand Down Expand Up @@ -287,7 +287,7 @@ verify_certs_server_toggled(GtkToggleButton *toggle_button, AccountSecurityTab *

gboolean verify_certs = gtk_toggle_button_get_active(toggle_button);

priv->account->setTlsVerifyServer(verify_certs);
priv->account->getAccountTLS()->setTlsVerifyServer(verify_certs);
}

static void
Expand All @@ -298,7 +298,7 @@ verify_certs_client_toggled(GtkToggleButton *toggle_button, AccountSecurityTab *

gboolean verify_certs = gtk_toggle_button_get_active(toggle_button);

priv->account->setTlsVerifyClient(verify_certs);
priv->account->getAccountTLS()->setTlsVerifyClient(verify_certs);
}

static void
Expand All @@ -309,7 +309,7 @@ require_incoming_certs_toggled(GtkToggleButton *toggle_button, AccountSecurityTa

gboolean require = gtk_toggle_button_get_active(toggle_button);

priv->account->setTlsRequireClientCertificate(require);
priv->account->getAccountTLS()->setTlsRequireClientCertificate(require);
}

static void
Expand All @@ -320,7 +320,7 @@ ca_cert_file_set(GtkFileChooser *file_chooser, AccountSecurityTab *self)

gchar *filename = gtk_file_chooser_get_filename(file_chooser);

priv->account->setTlsCaListCertificate(filename);
priv->account->getAccountTLS()->setTlsCaListCertificate(filename);
g_free(filename);
}

Expand All @@ -332,7 +332,7 @@ user_cert_file_set(GtkFileChooser *file_chooser, AccountSecurityTab *self)

gchar *filename = gtk_file_chooser_get_filename(file_chooser);

priv->account->setTlsCertificate(filename);
priv->account->getAccountTLS()->setTlsCertificate(filename);
g_free(filename);
}

Expand All @@ -344,7 +344,7 @@ private_key_file_set(GtkFileChooser *file_chooser, AccountSecurityTab *self)

gchar *filename = gtk_file_chooser_get_filename(file_chooser);

priv->account->setTlsPrivateKey(filename);
priv->account->getAccountTLS()->setTlsPrivateKey(filename);
g_free(filename);
}

Expand All @@ -354,7 +354,7 @@ private_key_password_changed(GtkEntry *entry, AccountSecurityTab *self)
g_return_if_fail(IS_ACCOUNT_SECURITY_TAB(self));
AccountSecurityTabPrivate *priv = ACCOUNT_SECURITY_TAB_GET_PRIVATE(self);

priv->account->setTlsPassword(gtk_entry_get_text(entry));
priv->account->getAccountTLS()->setTlsPassword(gtk_entry_get_text(entry));
}

static void
Expand Down Expand Up @@ -412,36 +412,36 @@ build_tab_view(AccountSecurityTab *self)

/* use TLS */
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->checkbutton_use_tls),
priv->account->isTlsEnabled());
priv->account->getAccountTLS()->isTlsEnabled());

/* disable certain options if TLS is off, or if its a RING account*/
gtk_widget_set_sensitive(priv->checkbutton_use_tls, not_ring);
gtk_widget_set_sensitive(priv->grid_tls_settings_0,
priv->account->isTlsEnabled());
priv->account->getAccountTLS()->isTlsEnabled());
gtk_widget_set_sensitive(priv->grid_tls_settings_1,
priv->account->isTlsEnabled() && not_ring);
priv->account->getAccountTLS()->isTlsEnabled() && not_ring);
gtk_widget_set_sensitive(priv->buttonbox_cipher_list,
priv->account->isTlsEnabled() && not_ring);
priv->account->getAccountTLS()->isTlsEnabled() && not_ring);
gtk_widget_set_sensitive(priv->treeview_cipher_list,
priv->account->isTlsEnabled() && not_ring);
priv->account->getAccountTLS()->isTlsEnabled() && not_ring);
gtk_widget_set_sensitive(priv->checkbutton_verify_certs_server,
priv->account->isTlsEnabled() && not_ring);
priv->account->getAccountTLS()->isTlsEnabled() && not_ring);
gtk_widget_set_sensitive(priv->checkbutton_verify_certs_client,
priv->account->isTlsEnabled() && not_ring);
priv->account->getAccountTLS()->isTlsEnabled() && not_ring);
gtk_widget_set_sensitive(priv->checkbutton_require_incoming_tls_certs,
priv->account->isTlsEnabled() && not_ring);
priv->account->getAccountTLS()->isTlsEnabled() && not_ring);
g_signal_connect(priv->checkbutton_use_tls, "toggled", G_CALLBACK(use_tls_toggled), self);

/* CA certificate */
Certificate *ca_cert = priv->account->tlsCaListCertificate();
Certificate *ca_cert = priv->account->getAccountTLS()->tlsCaListCertificate();
if (ca_cert) {
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(priv->filechooserbutton_ca_list),
ca_cert->path().toUtf8().constData());
}
g_signal_connect(priv->filechooserbutton_ca_list, "file-set", G_CALLBACK(ca_cert_file_set), self);

/* user certificate */
if ( (priv->user_cert = priv->account->tlsCertificate()) ) {
if ( (priv->user_cert = priv->account->getAccountTLS()->tlsCertificate()) ) {
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(priv->filechooserbutton_certificate),
priv->user_cert->path().toUtf8().constData()
);
Expand All @@ -463,7 +463,7 @@ build_tab_view(AccountSecurityTab *self)
if (priv->user_cert && priv->user_cert->requirePrivateKeyPassword()) {
gtk_entry_set_text(
GTK_ENTRY(priv->entry_password),
priv->account->tlsPassword().toUtf8().constData()
priv->account->getAccountTLS()->tlsPassword().toUtf8().constData()
);
gtk_widget_set_sensitive(priv->entry_password, TRUE);
gtk_widget_set_sensitive(priv->label_private_key_password, TRUE);
Expand All @@ -477,8 +477,8 @@ build_tab_view(AccountSecurityTab *self)

/* TLS protocol method */
priv->tls_method_selection = gtk_combo_box_set_qmodel(GTK_COMBO_BOX(priv->combobox_tls_protocol_method),
(QAbstractItemModel *)priv->account->tlsMethodModel(),
priv->account->tlsMethodModel()->selectionModel());
(QAbstractItemModel *)priv->account->getAccountTLS()->tlsMethodModel(),
priv->account->getAccountTLS()->tlsMethodModel()->selectionModel());

/* outgoing TLS server */
gtk_entry_set_text(GTK_ENTRY(priv->entry_tls_server_name),
Expand Down Expand Up @@ -531,19 +531,19 @@ build_tab_view(AccountSecurityTab *self)

/* server certs */
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->checkbutton_verify_certs_server),
priv->account->isTlsVerifyServer());
priv->account->getAccountTLS()->isTlsVerifyServer());
g_signal_connect(priv->checkbutton_verify_certs_server,
"toggled", G_CALLBACK(verify_certs_server_toggled), self);

/* client certs */
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->checkbutton_verify_certs_client),
priv->account->isTlsVerifyClient());
priv->account->getAccountTLS()->isTlsVerifyClient());
g_signal_connect(priv->checkbutton_verify_certs_client,
"toggled", G_CALLBACK(verify_certs_client_toggled), self);

/* incoming certs */
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->checkbutton_require_incoming_tls_certs),
priv->account->isTlsRequireClientCertificate());
priv->account->getAccountTLS()->isTlsRequireClientCertificate());
g_signal_connect(priv->checkbutton_require_incoming_tls_certs,
"toggled", G_CALLBACK(require_incoming_certs_toggled), self);

Expand All @@ -561,10 +561,10 @@ build_tab_view(AccountSecurityTab *self)
priv->account->isSrtpRtpFallback());
/* use TLS */
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->checkbutton_use_tls),
priv->account->isTlsEnabled());
priv->account->getAccountTLS()->isTlsEnabled());

/* CA certificate */
Certificate *ca_cert = priv->account->tlsCaListCertificate();
Certificate *ca_cert = priv->account->getAccountTLS()->tlsCaListCertificate();
if (ca_cert) {
gtk_file_chooser_set_filename(
GTK_FILE_CHOOSER(priv->filechooserbutton_ca_list),
Expand All @@ -578,7 +578,7 @@ build_tab_view(AccountSecurityTab *self)

/* user certificate */
QObject::disconnect(priv->cert_changed);
if ( (priv->user_cert = priv->account->tlsCertificate()) ) {
if ( (priv->user_cert = priv->account->getAccountTLS()->tlsCertificate()) ) {
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(priv->filechooserbutton_certificate),
priv->user_cert->path().toUtf8().constData()
);
Expand All @@ -603,7 +603,7 @@ build_tab_view(AccountSecurityTab *self)
if (priv->user_cert && priv->user_cert->requirePrivateKeyPassword()) {
gtk_entry_set_text(
GTK_ENTRY(priv->entry_password),
priv->account->tlsPassword().toUtf8().constData()
priv->account->getAccountTLS()->tlsPassword().toUtf8().constData()
);
gtk_widget_set_sensitive(priv->entry_password, TRUE);
gtk_widget_set_sensitive(priv->label_private_key_password, TRUE);
Expand All @@ -627,15 +627,15 @@ build_tab_view(AccountSecurityTab *self)

/* server certs */
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->checkbutton_verify_certs_server),
priv->account->isTlsVerifyServer());
priv->account->getAccountTLS()->isTlsVerifyServer());

/* client certs */
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->checkbutton_verify_certs_client),
priv->account->isTlsVerifyClient());
priv->account->getAccountTLS()->isTlsVerifyClient());

/* incoming certs */
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->checkbutton_require_incoming_tls_certs),
priv->account->isTlsRequireClientCertificate());
priv->account->getAccountTLS()->isTlsRequireClientCertificate());
}
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/accountvideotab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ video_enable(GtkToggleButton *checkbutton, AccountVideoTab *view)
{
g_return_if_fail(IS_ACCOUNT_VIDEO_TAB(view));
AccountVideoTabPrivate *priv = ACCOUNT_VIDEO_TAB_GET_PRIVATE(view);
priv->account->setVideoEnabled(gtk_toggle_button_get_active(checkbutton));
priv->account->getAccountMedia()->setVideoEnabled(gtk_toggle_button_get_active(checkbutton));
}

static void
Expand Down Expand Up @@ -196,7 +196,7 @@ build_tab_view(AccountVideoTab *view)

/* enable video checkbutton */
gtk_toggle_button_set_active(
GTK_TOGGLE_BUTTON(priv->checkbutton_enable), priv->account->isVideoEnabled());
GTK_TOGGLE_BUTTON(priv->checkbutton_enable), priv->account->getAccountMedia()->isVideoEnabled());
g_signal_connect(priv->checkbutton_enable, "toggled", G_CALLBACK(video_enable), view);

/* connect move codecs up/down signals */
Expand Down