This commit is contained in:
henrypp committed 2019-05-02 18:42:18 +06:00
1 parent d4242eaad9
commit 8f15bacf7a
13 files changed
+1290 -1217

No files matched your search

+42 -26
View File
@@ -10,6 +10,8 @@ void _app_timer_create (HWND hwnd, const MFILTER_APPS *ptr_apps, time_t seconds)
const time_t current_time = _r_unixtime_now ();
_r_fastlock_acquireexclusive (&lock_access);
for (size_t i = 0; i < ptr_apps->size (); i++)
{
PITEM_APP ptr_app = ptr_apps->at (i);
@@ -47,6 +49,8 @@ void _app_timer_create (HWND hwnd, const MFILTER_APPS *ptr_apps, time_t seconds)
}
}
_r_fastlock_releaseexclusive (&lock_access);
_wfp_create3filters (ptr_apps, __LINE__);
}
@@ -60,6 +64,8 @@ size_t _app_timer_remove (HWND hwnd, const MFILTER_APPS *ptr_apps)
MARRAY ids;
_r_fastlock_acquireexclusive (&lock_access);
for (size_t i = 0; i < ptr_apps->size (); i++)
{
PITEM_APP ptr_app = ptr_apps->at (i);
@@ -69,42 +75,51 @@ size_t _app_timer_remove (HWND hwnd, const MFILTER_APPS *ptr_apps)
ids.insert (ids.end (), ptr_app->mfarr.begin (), ptr_app->mfarr.end ());
ptr_app->mfarr.clear ();
ptr_app->is_haveerrors = false;
if (ptr_app->htimer)
{
if (DeleteTimerQueueTimer (config.htimer, ptr_app->htimer, nullptr))
{
ptr_app->htimer = nullptr;
ptr_app->timer = 0;
}
}
ptr_app->is_enabled = false;
if(ptr_app->timer)
ptr_app->timer = 0;
const size_t hash = _r_str_hash (ptr_app->original_path); // note: be carefull (!)
const size_t item = _app_getposition (hwnd, hash);
ptr_app->is_enabled = false;
if (item != LAST_VALUE)
const size_t app_hash = _r_str_hash (ptr_app->original_path); // note: be carefull (!)
const size_t item = _app_getposition (hwnd, app_hash);
const UINT listview_id = _app_getlistview_id (ptr_app->type);
if (item != LAST_VALUE)
{
if (!_app_isappexists (ptr_app) || ptr_app->is_temp)
{
if (!_app_isappexists (ptr_app) || ptr_app->is_temp)
{
SendDlgItemMessage (hwnd, IDC_APPS_PROFILE, LVM_DELETEITEM, item, 0);
_app_freeapplication (hash);
}
else
if (listview_id)
SendDlgItemMessage (hwnd, listview_id, LVM_DELETEITEM, item, 0);
_app_freeapplication (app_hash);
}
else
{
if (listview_id)
{
_r_fastlock_acquireshared (&lock_checkbox);
_r_listview_setitem (hwnd, IDC_APPS_PROFILE, item, 0, nullptr, LAST_VALUE, _app_getappgroup (hash, ptr_app));
_r_listview_setitemcheck (hwnd, IDC_APPS_PROFILE, item, ptr_app->is_enabled);
_r_listview_setitem (hwnd, listview_id, item, 0, nullptr, LAST_VALUE, _app_getappgroup (app_hash, ptr_app));
_r_listview_setitemcheck (hwnd, listview_id, item, ptr_app->is_enabled);
_r_fastlock_releaseshared (&lock_checkbox);
}
}
count += 1;
}
count += 1;
}
_r_fastlock_releaseexclusive (&lock_access);
_wfp_destroy2filters (&ids, __LINE__);
return count;
@@ -124,7 +139,6 @@ bool _app_istimersactive ()
if (_app_istimeractive (&p.second))
{
_r_fastlock_releaseshared (&lock_access);
return true;
}
}
@@ -136,25 +150,27 @@ bool _app_istimersactive ()
void CALLBACK _app_timer_callback (PVOID lparam, BOOLEAN)
{
_r_fastlock_acquireexclusive (&lock_access);
_r_fastlock_acquireshared (&lock_access);
const size_t hash = (size_t)lparam;
const PITEM_APP ptr_app = _app_getapplication (hash);
const size_t app_hash = (size_t)lparam;
const PITEM_APP ptr_app = _app_getapplication (app_hash);
const HWND hwnd = app.GetHWND ();
MFILTER_APPS rules;
rules.push_back (ptr_app);
const bool is_succcess = _app_timer_remove (hwnd, &rules);
_r_fastlock_releaseshared (&lock_access);
_r_fastlock_releaseexclusive (&lock_access);
const bool is_succcess = _app_timer_remove (hwnd, &rules);
if (is_succcess)
{
_app_listviewsort (hwnd, IDC_APPS_PROFILE);
_app_profile_save (hwnd);
const UINT listview_id = _app_gettab_id (hwnd);
_r_listview_redraw (hwnd, IDC_APPS_PROFILE);
_app_listviewsort (hwnd, listview_id);
_app_profile_save ();
_r_listview_redraw (hwnd, listview_id);
if (app.ConfigGet (L"IsNotificationsTimer", true).AsBool ())
app.TrayPopup (hwnd, UID, nullptr, NIIF_USER | (app.ConfigGet (L"IsNotificationsSound", true).AsBool () ? 0 : NIIF_NOSOUND), APP_NAME, _r_fmt (app.LocaleString (IDS_STATUS_TIMER_DONE, nullptr), ptr_app->display_name));