Skip to content

Commit

Permalink
refactor helper.c
Browse files Browse the repository at this point in the history
  • Loading branch information
henrypp committed Dec 1, 2021
1 parent f9fbcfd commit 4f20fed
Show file tree
Hide file tree
Showing 15 changed files with 713 additions and 1,524 deletions.
8 changes: 6 additions & 2 deletions simplewall.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -353,14 +353,16 @@
<ClCompile Include="..\routine\rapp.c" />
<ClCompile Include="..\routine\routine.c" />
<ClCompile Include="src\controls.c" />
<ClCompile Include="src\db.c" />
<ClCompile Include="src\editor.c" />
<ClCompile Include="src\helper.c" />
<ClCompile Include="src\icons.c" />
<ClCompile Include="src\log.c" />
<ClCompile Include="src\main.c" />
<ClCompile Include="src\network.c" />
<ClCompile Include="src\notifications.c" />
<ClCompile Include="src\packages.c" />
<ClCompile Include="src\profile.c" />
<ClCompile Include="src\profile2.c" />
<ClCompile Include="src\search.c" />
<ClCompile Include="src\security.c" />
<ClCompile Include="src\timer.c" />
Expand All @@ -375,15 +377,17 @@
<ClInclude Include="..\routine\rtypes.h" />
<ClInclude Include="src\app.h" />
<ClInclude Include="src\controls.h" />
<ClInclude Include="src\db.h" />
<ClInclude Include="src\editor.h" />
<ClInclude Include="src\global.h" />
<ClInclude Include="src\helper.h" />
<ClInclude Include="src\icons.h" />
<ClInclude Include="src\log.h" />
<ClInclude Include="src\main.h" />
<ClInclude Include="src\network.h" />
<ClInclude Include="src\notifications.h" />
<ClInclude Include="src\packages.h" />
<ClInclude Include="src\profile.h" />
<ClInclude Include="src\profile2.h" />
<ClInclude Include="src\resource.h" />
<ClInclude Include="src\search.h" />
<ClInclude Include="src\security.h" />
Expand Down
16 changes: 14 additions & 2 deletions simplewall.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,13 @@
<ClCompile Include="src\network.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\profile2.c">
<ClCompile Include="src\packages.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\icons.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\db.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
Expand Down Expand Up @@ -128,7 +134,13 @@
<ClInclude Include="src\network.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\profile2.h">
<ClInclude Include="src\packages.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\icons.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\db.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/controls.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,8 @@ PR_STRING _app_gettooltipbylparam (_In_ HWND hwnd, _In_ INT listview_id, _In_ UL
PR_STRING string;
PR_STRING string_tmp;

UNREFERENCED_PARAMETER (hwnd);

_r_obj_initializestringbuilder (&sr);

if ((listview_id >= IDC_APPS_PROFILE && listview_id <= IDC_APPS_UWP) || listview_id == IDC_RULE_APPS_ID)
Expand Down
22 changes: 10 additions & 12 deletions src/editor.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ INT_PTR CALLBACK EditorRuleProc (_In_ HWND hwnd, _In_ UINT msg, _In_ WPARAM wpar

if (hdc)
{
_r_dc_drawwindowdefault (hdc, hwnd, TRUE);
_r_dc_drawwindow (hdc, hwnd, TRUE);

EndPaint (hwnd, &ps);
}
Expand Down Expand Up @@ -459,7 +459,7 @@ INT_PTR CALLBACK EditorPagesProc (_In_ HWND hwnd, _In_ UINT msg, _In_ WPARAM wpa
{
index += 1;

string = _app_getprotoname (protos[i], AF_UNSPEC, TRUE);
string = _app_db_getprotoname (protos[i], AF_UNSPEC, TRUE);

_r_str_printf (buffer, RTL_NUMBER_OF (buffer), L"%s (%" TEXT (PRIu8) L")", string->buffer, protos[i]);

Expand All @@ -475,7 +475,7 @@ INT_PTR CALLBACK EditorPagesProc (_In_ HWND hwnd, _In_ UINT msg, _In_ WPARAM wpa
// unknown protocol
if (_r_combobox_getcurrentitem (hwnd, IDC_RULE_PROTOCOL_ID) == CB_ERR)
{
string = _app_getprotoname (context->ptr_rule->protocol, AF_UNSPEC, TRUE);
string = _app_db_getprotoname (context->ptr_rule->protocol, AF_UNSPEC, TRUE);

_r_str_printf (buffer, RTL_NUMBER_OF (buffer), L"%s (%" TEXT (PR_ULONG) L")", string->buffer, context->ptr_rule->protocol);

Expand Down Expand Up @@ -643,7 +643,7 @@ INT_PTR CALLBACK EditorPagesProc (_In_ HWND hwnd, _In_ UINT msg, _In_ WPARAM wpa
// app icon
if (GetDlgItem (hwnd, IDC_APP_ICON_ID))
{
context->hicon = _app_getfileiconsafe (context->ptr_app->app_hash);
context->hicon = _app_icons_getsafeapp_hicon (context->ptr_app->app_hash);

SendDlgItemMessage (hwnd, IDC_APP_ICON_ID, STM_SETICON, (WPARAM)context->hicon, 0);
}
Expand All @@ -659,8 +659,6 @@ INT_PTR CALLBACK EditorPagesProc (_In_ HWND hwnd, _In_ UINT msg, _In_ WPARAM wpa
// app signature
if (GetDlgItem (hwnd, IDC_APP_SIGNATURE_ID))
{
PR_STRING string;

string = _app_getappinfoparam2 (context->ptr_app->app_hash, INFO_SIGNATURE_STRING);

_r_ctrl_setstringformat (hwnd, IDC_APP_SIGNATURE_ID, L"%s: %s", _r_locale_getstring (IDS_SIGNATURE), _r_obj_getstringordefault (string, _r_locale_getstring (IDS_SIGN_UNSIGNED)));
Expand Down Expand Up @@ -956,7 +954,7 @@ INT_PTR CALLBACK EditorPagesProc (_In_ HWND hwnd, _In_ UINT msg, _In_ WPARAM wpa

case LVN_DELETEITEM:
{
PITEM_LISTVIEW_CONTEXT context;
PITEM_LISTVIEW_CONTEXT listview_context;
LPNMLISTVIEW lpnmlv;
INT listview_id;

Expand All @@ -966,12 +964,12 @@ INT_PTR CALLBACK EditorPagesProc (_In_ HWND hwnd, _In_ UINT msg, _In_ WPARAM wpa
if (!(listview_id == IDC_RULE_APPS_ID || listview_id == IDC_APP_RULES_ID))
break;

context = (PITEM_LISTVIEW_CONTEXT)lpnmlv->lParam;
listview_context = (PITEM_LISTVIEW_CONTEXT)lpnmlv->lParam;

if (!context)
if (!listview_context)
break;

_app_destroylistviewcontext (context);
_app_destroylistviewcontext (listview_context);

break;
}
Expand Down Expand Up @@ -1482,7 +1480,7 @@ INT_PTR CALLBACK EditorProc (_In_ HWND hwnd, _In_ UINT msg, _In_ WPARAM wparam,

if (hdc)
{
_r_dc_drawwindowdefault (hdc, hwnd, FALSE);
_r_dc_drawwindow (hdc, hwnd, FALSE);

EndPaint (hwnd, &ps);
}
Expand Down Expand Up @@ -1645,7 +1643,7 @@ INT_PTR CALLBACK EditorProc (_In_ HWND hwnd, _In_ UINT msg, _In_ WPARAM wparam,
context->ptr_rule->protocol = (UINT8)_r_combobox_getitemparam (hpage_general, IDC_RULE_PROTOCOL_ID, _r_combobox_getcurrentitem (hpage_general, IDC_RULE_PROTOCOL_ID));
context->ptr_rule->af = (ADDRESS_FAMILY)_r_combobox_getitemparam (hpage_general, IDC_RULE_VERSION_ID, _r_combobox_getcurrentitem (hpage_general, IDC_RULE_VERSION_ID));

string = _app_getprotoname (context->ptr_rule->protocol, context->ptr_rule->af, FALSE);
string = _app_db_getprotoname (context->ptr_rule->protocol, context->ptr_rule->af, FALSE);
_r_obj_movereference (&context->ptr_rule->protocol_str, string);

context->ptr_rule->direction = (FWP_DIRECTION)_r_calc_clamp (_r_ctrl_isradiobuttonchecked (hpage_general, IDC_RULE_DIRECTION_OUTBOUND, IDC_RULE_DIRECTION_ANY) - IDC_RULE_DIRECTION_OUTBOUND, FWP_DIRECTION_OUTBOUND, FWP_DIRECTION_MAX);
Expand Down
6 changes: 3 additions & 3 deletions src/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ DECLSPEC_SELECTANY PROFILE_DATA profile_info = {0};
DECLSPEC_SELECTANY PR_HASHTABLE apps_table = NULL;
DECLSPEC_SELECTANY PR_LIST rules_list = NULL;
DECLSPEC_SELECTANY PR_HASHTABLE rules_config = NULL;
DECLSPEC_SELECTANY PR_HASHTABLE network_table = NULL;
DECLSPEC_SELECTANY PR_HASHTABLE log_table = NULL;

DECLSPEC_SELECTANY PR_HASHTABLE cache_information = NULL;
Expand All @@ -49,7 +48,6 @@ DECLSPEC_SELECTANY R_QUEUED_LOCK lock_apply = PR_QUEUED_LOCK_INIT;
DECLSPEC_SELECTANY R_QUEUED_LOCK lock_rules = PR_QUEUED_LOCK_INIT;
DECLSPEC_SELECTANY R_QUEUED_LOCK lock_rules_config = PR_QUEUED_LOCK_INIT;
DECLSPEC_SELECTANY R_QUEUED_LOCK lock_loglist = PR_QUEUED_LOCK_INIT;
DECLSPEC_SELECTANY R_QUEUED_LOCK lock_network = PR_QUEUED_LOCK_INIT;
DECLSPEC_SELECTANY R_QUEUED_LOCK lock_profile = PR_QUEUED_LOCK_INIT;
DECLSPEC_SELECTANY R_QUEUED_LOCK lock_transaction = PR_QUEUED_LOCK_INIT;

Expand Down Expand Up @@ -88,13 +86,15 @@ DECLSPEC_SELECTANY const LONG64 timer_array[] =
#endif

#include "controls.h"
#include "db.h"
#include "editor.h"
#include "helper.h"
#include "icons.h"
#include "log.h"
#include "messages.h"
#include "network.h"
#include "notifications.h"
#include "profile2.h"
#include "packages.h"
#include "profile.h"
#include "search.h"
#include "security.h"
Expand Down
Loading

0 comments on commit 4f20fed

Please sign in to comment.