예제 #1
0
void active_protocol_c::stop_and_die(bool wait_worker_end)
{
    auto w = syncdata.lock_write();
    if (w().flags.is(F_DIP) || !w().flags.is(F_WORKER))
    {
        w().flags.set(F_DIP);
        return;
    }
    w().flags.set(F_DIP);
    if (ipcp) ipcp->something_happens();
    w.unlock();

    if (wait_worker_end)
    {
        auto lr = syncdata.lock_read();
        while( lr().flags.is(F_WORKER) )
        {
            if (ipcp) ipcp->something_happens();
            lr.unlock();
            Sleep(0);
            lr = syncdata.lock_read();
        }
    } else
        DEFERRED_UNIQUE_CALL( 0, DELEGATE(this,check_die), nullptr );
}
예제 #2
0
void active_protocol_c::save_config(bool wait)
{
    if (!ipcp) return;
    ts::Time t = ts::Time::current();

    auto w = syncdata.lock_write();
    if (w().flags.is(F_CONFIG_OK))
        if ((t - lastconfig) < 1000) return;

    w().flags.clear(F_CONFIG_OK|F_CONFIG_FAIL|F_SAVE_REQUEST|F_CONFIG_UPDATED);
    w().data.config.clear();
    w.unlock();

    if (!ipcp) return;
    ipcp->send( ipcw(AQ_SAVE_CONFIG) );
    DMSG("save request" << id);

    if (wait)
    {
        Sleep(10);
        while( !syncdata.lock_read()().flags.is(F_CONFIG_OK|F_CONFIG_FAIL) )
        {
            Sleep(10);
            sys_idle();
            if (!syncdata.lock_read()().flags.is(F_WORKER))
                return;
        }
        check_save(RID(),nullptr);

    } else
    {
        syncdata.lock_write()().flags.set(F_CFGSAVE_CHECKER);
        DEFERRED_UNIQUE_CALL( 0, DELEGATE(this,check_save), nullptr );
    }
}
예제 #3
0
bool active_protocol_c::check_die(RID, GUIPARAM)
{
    auto r = syncdata.lock_read();
    if (r().flags.is(F_WORKER))
    {
        // worker still works. waiting again
        if (ipcp) ipcp->something_happens();
        r.unlock();
        DEFERRED_UNIQUE_CALL(0.01, DELEGATE(this, check_die), nullptr);
    } else
    {
        r.unlock();
        TSDEL( this ); // actual death
    }
    return true;
}
예제 #4
0
bool active_protocol_c::check_save(RID, GUIPARAM)
{
    auto ttt = syncdata.lock_write();
    ttt().flags.clear(F_CFGSAVE_CHECKER);
    if (!ttt().flags.is(F_CONFIG_OK))
    {
        // config still not received. waiting again
        ttt().flags.set(F_CFGSAVE_CHECKER);
        DEFERRED_UNIQUE_CALL(0.01, DELEGATE(this, check_save), nullptr);
    }
    else
    {
        ttt().flags.clear(F_CONFIG_UPDATED);
        save_config( ttt().data.config );
    }
    return true;
}
예제 #5
0
bool gui_filterbar_c::do_contact_check(RID, GUIPARAM p)
{
    for (int n = ts::tmax(1, contacts().count() / 10 ); contact_index < contacts().count() && n > 0; --n)
    {
        contact_c &c = contacts().get(contact_index++);
        if (c.is_rootcontact())
        {
            contact_root_c *cr = ts::ptr_cast<contact_root_c *>(&c);

            if (cr->is_full_search_result())
            {
                cr->full_search_result(false);
                if (cr->gui_item) cr->gui_item->update_text();
            }

            if (cr->gui_item)
            {
                MODIFY(*cr->gui_item).visible(check_one(cr));
            }
        }
    }

    if (contact_index < contacts().count())
    {
        if (active)
        {
            gui_contactlist_c &cl = HOLD(getparent()).as<gui_contactlist_c>();
            cl.scroll_to_child(active, false);
        }
        DEFERRED_UNIQUE_CALL(0, DELEGATE(this, do_contact_check), 0);
    }
    else
    {
        apply_full_text_search_result();
    }

    return true;
}
예제 #6
0
/*virtual*/ bool mainrect_c::sq_evt(system_query_e qp, RID rid, evt_data_s &data)
{
    if (qp == SQ_RECT_CHANGED)
    {
        cfg().onclosereg( DELEGATE(this, onclosesave) );
        if (data.changed.manual)
        {
            rrect = getprops().screenrect();
            mrect = ts::wnd_get_max_size(rrect);
            DEFERRED_UNIQUE_CALL( 1.0, DELEGATE(this,saverectpos), nullptr );
        }
    }

    if (__super::sq_evt(qp, rid, data)) return true;

	switch( qp )
	{
	case SQ_DRAW:
        if (const theme_rect_s *tr = themerect())
		if (icons[0].info().sz.x > 0 && icons[1].info().sz.x)
        {
            ts::irect cr = tr->captionrect( getprops().currentszrect(), getprops().is_maximized() );

            ts::bitmap_c &icon = icons[ g_app->F_OFFLINE_ICON ? 1 : 0 ];
            //cr.lt.y += (cr.height() - icon.info().sz.y)/2;
            cr.lt.y += tr->captextadd.y;

            getengine().begin_draw();
            getengine().draw( cr.lt, icon.extbody(), ts::irect(0, icon.info().sz), true );
            getengine().end_draw();
        }
		break;
	}

    return false;
}