-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove flags #6
base: base-sha/047e5793a89789262ee0e17759f85e9f4abf31f0
Are you sure you want to change the base?
remove flags #6
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,15 +27,23 @@ using namespace std; | |
namespace iptux { | ||
|
||
PalInfo::PalInfo(in_addr ipv4, uint16_t port) | ||
: segdes(NULL), photo(NULL), sign(NULL), packetn(0), rpacketn(0), flags(0) { | ||
: segdes(NULL), photo(NULL), sign(NULL), packetn(0), rpacketn(0) { | ||
this->ipv4_ = ipv4; | ||
this->port_ = port; | ||
compatible = 0; | ||
online = 0; | ||
changed = 0; | ||
in_blacklist = 0; | ||
} | ||
|
||
PalInfo::PalInfo(const string& ipv4, uint16_t port) | ||
: segdes(NULL), photo(NULL), sign(NULL), packetn(0), rpacketn(0), flags(0) { | ||
: segdes(NULL), photo(NULL), sign(NULL), packetn(0), rpacketn(0) { | ||
this->ipv4_ = inAddrFromString(ipv4); | ||
this->port_ = port; | ||
compatible = 0; | ||
online = 0; | ||
changed = 0; | ||
in_blacklist = 0; | ||
} | ||
|
||
PalInfo::~PalInfo() { | ||
|
@@ -45,41 +53,29 @@ PalInfo::~PalInfo() { | |
} | ||
|
||
bool PalInfo::isCompatible() const { | ||
return FLAG_ISSET(this->flags, 0); | ||
return compatible; | ||
} | ||
|
||
bool PalInfo::isOnline() const { | ||
return FLAG_ISSET(this->flags, 1); | ||
return online; | ||
} | ||
|
||
bool PalInfo::isChanged() const { | ||
return FLAG_ISSET(this->flags, 2); | ||
return changed; | ||
} | ||
|
||
PalInfo& PalInfo::setCompatible(bool value) { | ||
if (value) { | ||
FLAG_SET(this->flags, 0); | ||
} else { | ||
FLAG_CLR(this->flags, 0); | ||
} | ||
this->compatible = value; | ||
return *this; | ||
} | ||
|
||
PalInfo& PalInfo::setOnline(bool value) { | ||
if (value) { | ||
FLAG_SET(this->flags, 1); | ||
} else { | ||
FLAG_CLR(this->flags, 1); | ||
} | ||
this->online = value; | ||
return *this; | ||
} | ||
|
||
PalInfo& PalInfo::setChanged(bool value) { | ||
Comment on lines
+68
to
77
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick: Avoid using 'this' pointer unnecessarily. Using 'this' pointer is redundant in this context. Consider removing it for cleaner code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this comment correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this comment helpful? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the comment type correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the comment area correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What type of LLM test could this comment become?
|
||
if (value) { | ||
FLAG_SET(this->flags, 2); | ||
} else { | ||
FLAG_CLR(this->flags, 2); | ||
} | ||
this->changed = value; | ||
return *this; | ||
} | ||
|
||
|
@@ -116,11 +112,12 @@ PalInfo& PalInfo::setGroup(const std::string& group) { | |
string PalInfo::toString() const { | ||
return stringFormat( | ||
"PalInfo(IP=%s,name=%s,segdes=%s,version=%s,user=%s,host=%s,group=%s," | ||
"photo=%s,sign=%s,iconfile=%s,encode=%s,packetn=%d,rpacketn=%d,flags=%d)", | ||
"photo=%s,sign=%s,iconfile=%s,encode=%s,packetn=%d,rpacketn=%d," | ||
"compatible=%d,online=%d,changed=%d,in_blacklist=%d)", | ||
inAddrToString(ipv4()).c_str(), name.c_str(), segdes, version.c_str(), | ||
user.c_str(), host.c_str(), group.c_str(), photo ? photo : "(NULL)", | ||
sign ? sign : "(NULL)", icon_file_.c_str(), encode.c_str(), int(packetn), | ||
int(rpacketn), int(flags)); | ||
int(rpacketn), compatible, online, changed, in_blacklist); | ||
} | ||
|
||
FileInfo::FileInfo() | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -18,7 +18,7 @@ static const char* CONFIG_SHARED_FILE_LIST = "shared_file_list"; | |||||||||||||||||||||||||||||||||
* 类构造函数. | ||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||
ProgramData::ProgramData(shared_ptr<IptuxConfig> config) | ||||||||||||||||||||||||||||||||||
: palicon(NULL), font(NULL), config(config), flags(0) { | ||||||||||||||||||||||||||||||||||
: palicon(NULL), font(NULL), config(config), need_restart_(0) { | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Consider initializing need_restart_ as a boolean. The variable need_restart_ is being initialized to 0, which is an integer. Since it is used as a boolean, it would be clearer to initialize it as false.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this comment correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this comment helpful? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the comment type correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the comment area correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What type of LLM test could this comment become?
|
||||||||||||||||||||||||||||||||||
gettimeofday(×tamp, NULL); | ||||||||||||||||||||||||||||||||||
InitSublayer(); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
@@ -59,14 +59,14 @@ void ProgramData::WriteProgData() { | |||||||||||||||||||||||||||||||||
config->SetString("pal_icon", palicon); | ||||||||||||||||||||||||||||||||||
config->SetString("panel_font", font); | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
config->SetBool("open_chat", FLAG_ISSET(flags, 7)); | ||||||||||||||||||||||||||||||||||
config->SetBool("hide_startup", FLAG_ISSET(flags, 6)); | ||||||||||||||||||||||||||||||||||
config->SetBool("open_transmission", FLAG_ISSET(flags, 5)); | ||||||||||||||||||||||||||||||||||
config->SetBool("use_enter_key", FLAG_ISSET(flags, 4)); | ||||||||||||||||||||||||||||||||||
config->SetBool("clearup_history", FLAG_ISSET(flags, 3)); | ||||||||||||||||||||||||||||||||||
config->SetBool("record_log", FLAG_ISSET(flags, 2)); | ||||||||||||||||||||||||||||||||||
config->SetBool("open_blacklist", FLAG_ISSET(flags, 1)); | ||||||||||||||||||||||||||||||||||
config->SetBool("proof_shared", FLAG_ISSET(flags, 0)); | ||||||||||||||||||||||||||||||||||
config->SetBool("open_chat", open_chat); | ||||||||||||||||||||||||||||||||||
config->SetBool("hide_startup", hide_startup); | ||||||||||||||||||||||||||||||||||
config->SetBool("open_transmission", open_transmission); | ||||||||||||||||||||||||||||||||||
config->SetBool("use_enter_key", use_enter_key); | ||||||||||||||||||||||||||||||||||
config->SetBool("clearup_history", clearup_history); | ||||||||||||||||||||||||||||||||||
config->SetBool("record_log", record_log); | ||||||||||||||||||||||||||||||||||
config->SetBool("open_blacklist", open_blacklist); | ||||||||||||||||||||||||||||||||||
config->SetBool("proof_shared", proof_shared); | ||||||||||||||||||||||||||||||||||
Comment on lines
+62
to
+69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Check for consistency in naming conventions. Ensure that the new variable names (e.g., open_chat, hide_startup) are consistent with the rest of the codebase. This helps maintain readability and uniformity.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this comment correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this comment helpful? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the comment type correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the comment area correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What type of LLM test could this comment become?
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
config->SetString("access_shared_limit", passwd); | ||||||||||||||||||||||||||||||||||
config->SetInt("send_message_retry_in_us", send_message_retry_in_us); | ||||||||||||||||||||||||||||||||||
|
@@ -133,14 +133,14 @@ void ProgramData::ReadProgData() { | |||||||||||||||||||||||||||||||||
palicon = g_strdup(config->GetString("pal_icon", "icon-qq.png").c_str()); | ||||||||||||||||||||||||||||||||||
font = g_strdup(config->GetString("panel_font", "Sans Serif 10").c_str()); | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
FLAG_SET(flags, 7, config->GetBool("open_chat")); | ||||||||||||||||||||||||||||||||||
FLAG_SET(flags, 6, config->GetBool("hide_startup")); | ||||||||||||||||||||||||||||||||||
FLAG_SET(flags, 5, config->GetBool("open_transmission")); | ||||||||||||||||||||||||||||||||||
FLAG_SET(flags, 4, config->GetBool("use_enter_key")); | ||||||||||||||||||||||||||||||||||
FLAG_SET(flags, 3, config->GetBool("clearup_history")); | ||||||||||||||||||||||||||||||||||
FLAG_SET(flags, 2, config->GetBool("record_log", true)); | ||||||||||||||||||||||||||||||||||
FLAG_SET(flags, 1, config->GetBool("open_blacklist")); | ||||||||||||||||||||||||||||||||||
FLAG_SET(flags, 0, config->GetBool("proof_shared")); | ||||||||||||||||||||||||||||||||||
open_chat = config->GetBool("open_chat"); | ||||||||||||||||||||||||||||||||||
hide_startup = config->GetBool("hide_startup"); | ||||||||||||||||||||||||||||||||||
open_transmission = config->GetBool("open_transmission"); | ||||||||||||||||||||||||||||||||||
use_enter_key = config->GetBool("use_enter_key"); | ||||||||||||||||||||||||||||||||||
clearup_history = config->GetBool("clearup_history"); | ||||||||||||||||||||||||||||||||||
record_log = config->GetBool("record_log", true); | ||||||||||||||||||||||||||||||||||
open_blacklist = config->GetBool("open_blacklist"); | ||||||||||||||||||||||||||||||||||
proof_shared = config->GetBool("proof_shared"); | ||||||||||||||||||||||||||||||||||
Comment on lines
+136
to
+143
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Consider adding default values for GetBool calls. For robustness, consider providing default values for the GetBool calls, similar to how it's done for record_log.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this comment correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this comment helpful? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the comment type correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the comment area correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What type of LLM test could this comment become?
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
passwd = config->GetString("access_shared_limit"); | ||||||||||||||||||||||||||||||||||
send_message_retry_in_us = | ||||||||||||||||||||||||||||||||||
|
@@ -207,43 +207,35 @@ void ProgramData::Unlock() { | |||||||||||||||||||||||||||||||||
mutex.unlock(); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
bool ProgramData::IsAutoOpenCharDialog() const { | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (typo): Typo in method name. The method name was corrected from IsAutoOpenCharDialog to IsAutoOpenChatDialog. Ensure that all references to this method are updated accordingly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this comment correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this comment helpful? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the comment type correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the comment area correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What type of LLM test could this comment become?
|
||||||||||||||||||||||||||||||||||
return FLAG_ISSET(flags, 7); | ||||||||||||||||||||||||||||||||||
bool ProgramData::IsAutoOpenChatDialog() const { | ||||||||||||||||||||||||||||||||||
return open_chat; | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
bool ProgramData::IsAutoHidePanelAfterLogin() const { | ||||||||||||||||||||||||||||||||||
return FLAG_ISSET(flags, 6); | ||||||||||||||||||||||||||||||||||
return hide_startup; | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
bool ProgramData::IsAutoOpenFileTrans() const { | ||||||||||||||||||||||||||||||||||
return FLAG_ISSET(flags, 5); | ||||||||||||||||||||||||||||||||||
return open_transmission; | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
bool ProgramData::IsEnterSendMessage() const { | ||||||||||||||||||||||||||||||||||
return FLAG_ISSET(flags, 4); | ||||||||||||||||||||||||||||||||||
return use_enter_key; | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
bool ProgramData::IsAutoCleanChatHistory() const { | ||||||||||||||||||||||||||||||||||
return FLAG_ISSET(flags, 3); | ||||||||||||||||||||||||||||||||||
return clearup_history; | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
bool ProgramData::IsSaveChatHistory() const { | ||||||||||||||||||||||||||||||||||
return FLAG_ISSET(flags, 2); | ||||||||||||||||||||||||||||||||||
return record_log; | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
bool ProgramData::IsUsingBlacklist() const { | ||||||||||||||||||||||||||||||||||
return FLAG_ISSET(flags, 1); | ||||||||||||||||||||||||||||||||||
return open_blacklist; | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
bool ProgramData::IsFilterFileShareRequest() const { | ||||||||||||||||||||||||||||||||||
return FLAG_ISSET(flags, 0); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
void ProgramData::SetFlag(int idx, bool flag) { | ||||||||||||||||||||||||||||||||||
if (flag) { | ||||||||||||||||||||||||||||||||||
FLAG_SET(flags, idx); | ||||||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||||||
FLAG_CLR(flags, idx); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
return proof_shared; | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
ProgramData& ProgramData::SetUsingBlacklist(bool value) { | ||||||||||||||||||||||||||||||||||
SetFlag(1, value); | ||||||||||||||||||||||||||||||||||
open_blacklist = value; | ||||||||||||||||||||||||||||||||||
return *this; | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Consider using boolean type for flags.
The variables compatible, online, changed, and in_blacklist are being initialized to 0. Since these are used as boolean flags, it would be clearer to use the boolean type and initialize them to false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comment correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comment helpful?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the comment type correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the comment area correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What type of LLM test could this comment become?