Esempio n. 1
0
/**
 * @brief Set a timeout to disconnect after no activity
 * @param e The #Esql object (NOT NULL)
 * @param timeout The timeout in seconds
 *
 * Use this function to apply a timer policy to an Esql object and force disconnection
 * after @p timeout seconds of inactivity.
 * @note Setting a value <= 0 will disable this feature.
 */
void
esql_connect_timeout_set(Esql  *e,
                         double timeout)
{
   EINA_SAFETY_ON_NULL_RETURN(e);

   e->timeout = timeout;
   if (e->pool)
     {
        esql_pool_connect_timeout_set((Esql_Pool*)e, timeout);
        return;
     }
   if (timeout > 0.0)
     {
        if (e->timeout_timer)
          {
             ecore_timer_interval_set(e->timeout_timer, e->timeout);
             ecore_timer_reset(e->timeout_timer);
          }
        else e->timeout_timer = ecore_timer_add(timeout, (Ecore_Task_Cb)esql_timeout_cb, e);
     }
   else
     {
        ecore_timer_del(e->timeout_timer);
        e->timeout_timer = NULL;
        e->timeout = 0;
     }
}
Esempio n. 2
0
void
_ecore_pa_time_restart(pa_time_event *event, const struct timeval *tv)
{
   struct timeval now;
   double interval;

   /* If tv is NULL disable timer */
   if (!tv)
     {
        ecore_timer_del(event->timer);
        event->timer = NULL;
        return;
     }

   event->tv = *tv;

   if (gettimeofday(&now, NULL) == -1)
     {
        ERR("Failed to get the current time!");
        return;
     }

   interval = (tv->tv_sec - now.tv_sec) + (tv->tv_usec - now.tv_usec) / 1000;
   if (event->timer)
     {
        event->timer = ecore_timer_add(interval, _ecore_time_wrapper, event);
     }
   else
     {
        ecore_timer_interval_set(event->timer, interval);
        ecore_timer_reset(event->timer);
     }
}
Esempio n. 3
0
static void
_ecore_event_evas_push_mouse_move(Ecore_Event_Mouse_Move *e)
{
   Ecore_Event_Last *eel;
   Eina_List *l;

   if (!_last_events_enable) return;

   EINA_LIST_FOREACH(_last_events, l, eel)
     switch (eel->state)
       {
        case ECORE_INPUT_NONE:
        case ECORE_INPUT_UP:
        case ECORE_INPUT_CANCEL:
           /* (none, up, or cancel) => move, sounds fine to me */
           break;
        case ECORE_INPUT_DOWN:
        case ECORE_INPUT_MOVE:
           /* Down and moving, let's see */
           if (eel->ev)
             {
                /* Add some delay to the timer */
                ecore_timer_reset(eel->timer);
                /* Update position */
                eel->ev->x = e->x;
                eel->ev->y = e->y;
                eel->ev->root.x = e->root.x;
                eel->ev->root.y = e->root.y;
                eel->state = ECORE_INPUT_MOVE;
                break;
             }
           /* FIXME: Timer did expire, do something maybe */
           break;
       }
}
Esempio n. 4
0
File: shotgun.c Progetto: Limsik/e17
static Eina_Bool
ev_write(Shotgun_Auth *auth, int type __UNUSED__, Ecore_Con_Event_Server_Write *ev)
{
   if ((auth != ecore_con_server_data_get(ev->server)) || (!auth))
     return ECORE_CALLBACK_PASS_ON;
   ecore_timer_reset(auth->keepalive);
   return ECORE_CALLBACK_RENEW;
}
void
systray_xembed_size_updated(Instance_Xembed *xembed)
{

   if (xembed->visibility_timer)
     ecore_timer_reset(xembed->visibility_timer);
   else
     xembed->visibility_timer = ecore_timer_add(0.15, (Ecore_Task_Cb)_systray_xembed_visible_check, xembed);
}
Esempio n. 6
0
File: shotgun.c Progetto: Limsik/e17
static Eina_Bool
ping(Shotgun_Auth *auth)
{
   /**
    * Sends ping request to the server (iq tag)
    * (Re)Init the timeout timer, increase the pending pings counter
    */
   xml_iq_ping_write(auth);
   auth->pending_ping++;
   ecore_timer_reset(auth->et_ping_timeout);
   ecore_timer_thaw(auth->et_ping_timeout);

   return EINA_TRUE;
}
Esempio n. 7
0
static void 
_e_pointer_active_handle(E_Pointer *ptr)
{
   _e_pointer_active(ptr);
   if (ptr->idle_tmr)
     ecore_timer_reset(ptr->idle_tmr);
   else
     {
        E_FREE_FUNC(ptr->idle_poll, ecore_poller_del);
        if (e_powersave_mode_get() >= E_POWERSAVE_MODE_MEDIUM) return;
        if (!e_config->idle_cursor) return;
        ptr->idle_tmr = ecore_timer_loop_add(1.0, _e_pointer_cb_idle_pre, ptr);
     }
}
Esempio n. 8
0
Eina_Bool
esql_connect_handler(Esql             *e,
                     Ecore_Fd_Handler *fdh)
{
   int ret;
   DBG("(e=%p, fdh=%p, qid=%u)", e, fdh, e->cur_id);

   if (fdh)
     ecore_main_fd_handler_active_set(fdh, 0);
   if (e->pool_member)
     INFO("Pool member %u: Running io", e->pool_id);
   else
     INFO("Running io");
   if (e->timeout_timer) ecore_timer_reset(e->timeout_timer);

   ret = e->backend.io(e);
   switch (ret)
     {
      case 0:
        esql_call_complete(e);
        break;

      case ECORE_FD_READ | ECORE_FD_WRITE:
        if (fdh)
          ecore_main_fd_handler_active_set(fdh, ECORE_FD_READ | ECORE_FD_WRITE);
        break;

      case ECORE_FD_READ:
        ecore_main_fd_handler_active_set(fdh, ECORE_FD_READ);
        break;

      case ECORE_FD_WRITE:
        ecore_main_fd_handler_active_set(fdh, ECORE_FD_WRITE);
        break;

      default:
        ERR("Error return from io()");
        esql_event_error(e);
     }
   return ECORE_CALLBACK_RENEW;
}
Esempio n. 9
0
File: shotgun.c Progetto: Limsik/e17
static Eina_Bool
data(Shotgun_Auth *auth, int type __UNUSED__, Ecore_Con_Event_Server_Data *ev)
{
   char *recv, *data, *p;
   size_t size;

   if ((auth != ecore_con_server_data_get(ev->server)) || (!auth))
     return ECORE_CALLBACK_PASS_ON;

   ecore_timer_reset(auth->keepalive);
   if (ev->size == 1)
     {
        DBG("Received carriage return");
        return ECORE_CALLBACK_RENEW;
     }
   else if ((ev->size == 38) &&
            (!memcmp(ev->data, "<?xml version=\"1.0", sizeof("<?xml version=\"1.0") - 1)) &&
            (((unsigned char*)ev->data)[ev->size - 1] == '>'))
     {
        DBG("Received xml version tag");
        return ECORE_CALLBACK_RENEW;
     }
   if (eina_log_domain_level_check(shotgun_log_dom, EINA_LOG_LEVEL_DBG))
     {
        recv = alloca(ev->size + 1);
        memcpy(recv, ev->data, ev->size);
        for (p = recv + ev->size - 1; isspace(*p); p--)
          *p = 0;
        recv[ev->size] = 0;
        DBG("Receiving %i bytes:\n%s", ev->size, recv);
     }

   if (!shotgun_data_detect(auth, ev))
     return ECORE_CALLBACK_RENEW;

   if (auth->state < SHOTGUN_CONNECTION_STATE_CONNECTED)
     {
        shotgun_login(auth, ev);
        return ECORE_CALLBACK_RENEW;
     }

   data = auth->buf ? (char*)eina_strbuf_string_get(auth->buf) : (char*)ev->data;
   size = auth->buf ? eina_strbuf_length_get(auth->buf) : (size_t)ev->size;

   switch (shotgun_data_tokenize(auth, ev))
     {
      case SHOTGUN_DATA_TYPE_MSG:
        shotgun_message_feed(auth, data, size);
        break;
      case SHOTGUN_DATA_TYPE_IQ:
        shotgun_iq_feed(auth, data, size);
        break;
      case SHOTGUN_DATA_TYPE_PRES:
        shotgun_presence_feed(auth, data, size);
        break;
      default:
        ERR("UNPARSABLE TAG %d", shotgun_data_tokenize(auth, ev));
        break;
     }
   if (auth->buf) eina_strbuf_free(auth->buf);
   auth->buf = NULL;

   return ECORE_CALLBACK_RENEW;
}