Skip to content

Commit

Permalink
Merge pull request #614 from Chilledheart/gui_dont_display_invalid_me…
Browse files Browse the repository at this point in the history
…thod

ios: dont display invalid method
  • Loading branch information
Chilledheart committed Jan 4, 2024
2 parents 2dedf57 + 3d0b028 commit 094ab39
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 25 deletions.
12 changes: 6 additions & 6 deletions src/gtk/yass_window.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2019-2022 Chilledheart */
/* Copyright (c) 2019-2024 Chilledheart */

#include "gtk/yass_window.hpp"

Expand Down Expand Up @@ -175,13 +175,13 @@ YASSWindow::YASSWindow()
password_ = GTK_ENTRY(gtk_entry_new());
static const char* const method_names[] = {
#define XX(num, name, string) string,
CIPHER_METHOD_MAP(XX)
CIPHER_METHOD_VALID_MAP(XX)
#undef XX
};

method_ = GTK_COMBO_BOX_TEXT(gtk_combo_box_text_new());

for (uint32_t i = 1; i < sizeof(method_names) / sizeof(method_names[0]);
for (uint32_t i = 0; i < sizeof(method_names) / sizeof(method_names[0]);
++i) {
gtk_combo_box_text_append_text(method_, method_names[i]);
}
Expand Down Expand Up @@ -410,16 +410,16 @@ void YASSWindow::LoadChanges() {

static const int method_ids[] = {
#define XX(num, name, string) num,
CIPHER_METHOD_MAP(XX)
CIPHER_METHOD_VALID_MAP(XX)
#undef XX
};
uint32_t i;
for (i = 1; i < sizeof(method_ids) / sizeof(method_ids[0]); ++i) {
for (i = 0; i < sizeof(method_ids) / sizeof(method_ids[0]); ++i) {
if (cipher_method == method_ids[i])
break;
}

gtk_combo_box_set_active(GTK_COMBO_BOX(method_), i - 1);
gtk_combo_box_set_active(GTK_COMBO_BOX(method_), i);

gtk_entry_set_text(local_host_, local_host_str.c_str());
gtk_entry_set_text(local_port_, local_port_str.c_str());
Expand Down
12 changes: 6 additions & 6 deletions src/gtk4/yass_window.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2019-2023 Chilledheart */
/* Copyright (c) 2019-2024 Chilledheart */

#include "gtk4/yass_window.hpp"

Expand Down Expand Up @@ -150,13 +150,13 @@ YASSWindow::YASSWindow(GApplication *app)

static const char* const method_names[] = {
#define XX(num, name, string) string,
CIPHER_METHOD_MAP(XX)
CIPHER_METHOD_VALID_MAP(XX)
#undef XX
};

GtkComboBoxText *method = GTK_COMBO_BOX_TEXT(impl_->method);

for (uint32_t i = 1; i < sizeof(method_names) / sizeof(method_names[0]);
for (uint32_t i = 0; i < sizeof(method_names) / sizeof(method_names[0]);
++i) {
gtk_combo_box_text_append_text(method, method_names[i]);
}
Expand Down Expand Up @@ -343,16 +343,16 @@ void YASSWindow::LoadChanges() {

static const int method_ids[] = {
#define XX(num, name, string) num,
CIPHER_METHOD_MAP(XX)
CIPHER_METHOD_VALID_MAP(XX)
#undef XX
};
uint32_t i;
for (i = 1; i < sizeof(method_ids) / sizeof(method_ids[0]); ++i) {
for (i = 0; i < sizeof(method_ids) / sizeof(method_ids[0]); ++i) {
if (cipher_method == method_ids[i])
break;
}

gtk_combo_box_set_active(GTK_COMBO_BOX(impl_->method), i - 1);
gtk_combo_box_set_active(GTK_COMBO_BOX(impl_->method), i);

gtk_editable_set_text(GTK_EDITABLE(impl_->local_host), local_host_str.c_str());
gtk_editable_set_text(GTK_EDITABLE(impl_->local_port), local_port_str.c_str());
Expand Down
2 changes: 0 additions & 2 deletions src/ios/YassAppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,11 @@ - (void)OnStartSaveAndLoadInstance:(NETunnelProviderManager*) vpn_manager {
#endif
auto ips_v4 = worker_.GetRemoteIpsV4();
NSMutableArray *remote_ips_v4 = [[NSMutableArray alloc] init];
[remote_ips_v4 addObject: @"127.0.0.1"];
for (const auto & ip_v4 : ips_v4) {
[remote_ips_v4 addObject:@(ip_v4.c_str())];
}
auto ips_v6 = worker_.GetRemoteIpsV6();
NSMutableArray *remote_ips_v6 = [[NSMutableArray alloc] init];
[remote_ips_v6 addObject: @"::1"];
for (const auto & ip_v6 : ips_v6) {
[remote_ips_v6 addObject:@(ip_v6.c_str())];
}
Expand Down
2 changes: 1 addition & 1 deletion src/ios/YassViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ - (void)viewDidLoad {

cipher_methods_ = @[
#define XX(num, name, string) @string,
CIPHER_METHOD_MAP(XX)
CIPHER_METHOD_VALID_MAP(XX)
#undef XX
];
current_cipher_method_ = nil;
Expand Down
8 changes: 4 additions & 4 deletions src/mac/YassViewController.mm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2022 Chilledheart */
/* Copyright (c) 2022-2024 Chilledheart */

#import "mac/YassViewController.h"

Expand Down Expand Up @@ -55,15 +55,15 @@ - (void)viewDidLoad {
[self.cipherMethod removeAllItems];
NSString* methodStrings[] = {
#define XX(num, name, string) @string,
CIPHER_METHOD_MAP(XX)
CIPHER_METHOD_VALID_MAP(XX)
#undef XX
};
for (uint32_t i = 1; i < sizeof(methodStrings) / sizeof(methodStrings[0]);
for (uint32_t i = 0; i < sizeof(methodStrings) / sizeof(methodStrings[0]);
++i) {
[self.cipherMethod addItemWithObjectValue:methodStrings[i]];
}
self.cipherMethod.numberOfVisibleItems =
sizeof(methodStrings) / sizeof(methodStrings[0]) - 1;
sizeof(methodStrings) / sizeof(methodStrings[0]);

[self.autoStart
setState:(CheckLoginItemStatus(nullptr) ? NSControlStateValueOn
Expand Down
12 changes: 6 additions & 6 deletions src/win32/yass_frame.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2022 Chilledheart */
/* Copyright (c) 2022-2024 Chilledheart */

#include "win32/yass_frame.hpp"

Expand Down Expand Up @@ -402,12 +402,12 @@ int CYassFrame::Create(const wchar_t* className,
// Right Panel
const wchar_t* method_strings[] = {
#define XX(num, name, string) L##string,
CIPHER_METHOD_MAP(XX)
CIPHER_METHOD_VALID_MAP(XX)
#undef XX
};
DWORD method_nums[] = {
#define XX(num, name, string) static_cast<DWORD>(num),
CIPHER_METHOD_MAP(XX)
CIPHER_METHOD_VALID_MAP(XX)
#undef XX
};

Expand Down Expand Up @@ -449,10 +449,10 @@ int CYassFrame::Create(const wchar_t* className,
method_combo_box_ = CreateComboBox(CBS_DROPDOWNLIST, m_hWnd,
IDC_COMBOBOX_METHOD, hInstance);

int method_count = sizeof(method_strings) / sizeof(method_strings[0]) - 1;
int method_count = sizeof(method_strings) / sizeof(method_strings[0]);
for (int i = 0; i < method_count; ++i) {
ComboBox_AddString(method_combo_box_, method_strings[i + 1]);
ComboBox_SetItemData(method_combo_box_, i, method_nums[i + 1]);
ComboBox_AddString(method_combo_box_, method_strings[i]);
ComboBox_SetItemData(method_combo_box_, i, method_nums[i]);
}

ComboBox_SetMinVisible(method_combo_box_, method_count);
Expand Down

0 comments on commit 094ab39

Please sign in to comment.