Ecore_File_Monitor *
ecore_file_monitor_backend_add(const char *path,
                            void (*func) (void *data, Ecore_File_Monitor *em,
                                          Ecore_File_Event event,
                                          const char *path),
                            void *data)
{
   Ecore_File_Monitor *em;
   size_t len;

   if (!path) return NULL;
   if (!func) return NULL;

   em = calloc(1, sizeof(Ecore_File_Monitor_Poll));
   if (!em) return NULL;

   if (!_timer)
     _timer = ecore_timer_add(_interval, _ecore_file_monitor_poll_handler, NULL);
   else
     ecore_timer_interval_set(_timer, ECORE_FILE_INTERVAL_MIN);

   em->path = strdup(path);
   len = strlen(em->path);
   if (em->path[len - 1] == '/' && strcmp(em->path, "/"))
     em->path[len - 1] = 0;

   em->func = func;
   em->data = data;

   ECORE_FILE_MONITOR_POLL(em)->mtime = ecore_file_mod_time(em->path);
   _monitors = ECORE_FILE_MONITOR(eina_inlist_append(EINA_INLIST_GET(_monitors), EINA_INLIST_GET(em)));

   if (ecore_file_exists(em->path))
     {
        if (ecore_file_is_dir(em->path))
          {
             /* Check for subdirs */
             Eina_List *files;
             char *file;

             files = ecore_file_ls(em->path);
             EINA_LIST_FREE(files, file)
                    {
                       Ecore_File *f;
                       char buf[PATH_MAX];

                       f = calloc(1, sizeof(Ecore_File));
                       if (!f)
                    {
                       free(file);
                         continue;
                    }

                       snprintf(buf, sizeof(buf), "%s/%s", em->path, file);
                       f->name = file;
                       f->mtime = ecore_file_mod_time(buf);
                       f->is_dir = ecore_file_is_dir(buf);
                       em->files = (Ecore_File *) eina_inlist_append(EINA_INLIST_GET(em->files), EINA_INLIST_GET(f));
                    }
          }
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);
     }
}
Exemple #3
0
   static Eina_Bool
_weather_cb_check(void *data)
{
   Instance *inst;

   printf("CHECK\n");
   if (!(inst = data)) return EINA_FALSE;
   if (inst->server) ecore_con_server_del(inst->server);
   inst->server = NULL;

   if (inst->weather->proxy.port != 0)
     inst->server =
	ecore_con_server_connect(ECORE_CON_REMOTE_SYSTEM, inst->weather->proxy.host,
	      inst->weather->proxy.port, inst);
   else
     {
     inst->server =
	ecore_con_server_connect(ECORE_CON_REMOTE_SYSTEM, inst->host, 80, inst);

   printf("CHECX %p\n", inst->server);
     }

   if (!inst->server) return EINA_FALSE;

   ecore_timer_interval_set(inst->check_timer, inst->weather->poll_time);
   return EINA_TRUE;
}
Exemple #4
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;
     }
}
Exemple #5
0
   static Eina_Bool
_weather_cb_check(void *data)
{
   Instance *inst;

   if (!(inst = data)) return EINA_FALSE;
   if (inst->server) ecore_con_server_del(inst->server);
   inst->server = NULL;

   if (inst->weather->proxy.port != 0)
     inst->server =
	ecore_con_server_connect(ECORE_CON_REMOTE_SYSTEM, inst->weather->proxy.host,
	      inst->weather->proxy.port, inst);
   else
     inst->server =
	ecore_con_server_connect(ECORE_CON_REMOTE_SYSTEM, inst->host, 80, inst);

   if (!inst->server)
     {
        inst->check_timer = NULL;
        return ECORE_CALLBACK_CANCEL;
     }
   ecore_timer_interval_set(inst->check_timer, inst->weather->poll_time);
   return ECORE_CALLBACK_RENEW;
}
Exemple #6
0
void
shotgun_ping_timeout_set(Shotgun_Auth *auth, double timeout)
{
   EINA_SAFETY_ON_NULL_RETURN(auth);
   auth->ping_timeout = timeout;
   if (auth->et_ping_timeout) 
      ecore_timer_interval_set(auth->et_ping_timeout, auth->ping_timeout);
}
Exemple #7
0
void
shotgun_ping_delay_set(Shotgun_Auth *auth, double delay)
{
   EINA_SAFETY_ON_NULL_RETURN(auth);
   auth->ping_delay = delay;
   if (auth->et_ping) 
      ecore_timer_interval_set(auth->et_ping, auth->ping_delay);
}
Exemple #8
0
static Eina_Bool
_on_clock_val_up(void *data)
{
   ELM_CLOCK_DATA_GET(data, sd);

   if (!sd->edit) goto clock_val_up_cancel;
   if (!sd->sel_obj) goto clock_val_up_cancel;
   if (sd->sel_obj == sd->digit[0])
     {
        sd->hrs = sd->hrs + 12;
        if (sd->hrs >= 24) sd->hrs -= 24;
     }
   if (sd->sel_obj == sd->digit[1])
     {
        sd->hrs = sd->hrs + 1;
        if (sd->hrs >= 24) sd->hrs -= 24;
     }
   if (sd->sel_obj == sd->digit[2])
     {
        sd->min = sd->min + 10;
        if (sd->min >= 60) sd->min -= 60;
     }
   if (sd->sel_obj == sd->digit[3])
     {
        sd->min = sd->min + 1;
        if (sd->min >= 60) sd->min -= 60;
     }
   if (sd->sel_obj == sd->digit[4])
     {
        sd->sec = sd->sec + 10;
        if (sd->sec >= 60) sd->sec -= 60;
     }
   if (sd->sel_obj == sd->digit[5])
     {
        sd->sec = sd->sec + 1;
        if (sd->sec >= 60) sd->sec -= 60;
     }
   if (sd->sel_obj == sd->am_pm_obj)
     {
        sd->hrs = sd->hrs + 12;
        if (sd->hrs > 23) sd->hrs -= 24;
     }

   sd->interval = sd->interval / 1.05;
   ecore_timer_interval_set(sd->spin, sd->interval);
   _time_update(data, EINA_FALSE);
   eo_do(data, eo_event_callback_call(ELM_CLOCK_EVENT_CHANGED, NULL));
   return ECORE_CALLBACK_RENEW;

clock_val_up_cancel:

   sd->spin = NULL;

   return ECORE_CALLBACK_CANCEL;
}
Exemple #9
0
static Eina_Bool
_on_clock_val_down(void *data)
{
   ELM_CLOCK_DATA_GET(data, sd);

   if (!sd->edit) goto clock_val_down_cancel;
   if (!sd->sel_obj) goto clock_val_down_cancel;
   if (sd->sel_obj == sd->digit[0])
     {
        sd->hrs = sd->hrs - 12;
        if (sd->hrs < 0) sd->hrs += 24;
     }
   if (sd->sel_obj == sd->digit[1])
     {
        sd->hrs = sd->hrs - 1;
        if (sd->hrs < 0) sd->hrs += 24;
     }
   if (sd->sel_obj == sd->digit[2])
     {
        sd->min = sd->min - 10;
        if (sd->min < 0) sd->min += 60;
     }
   if (sd->sel_obj == sd->digit[3])
     {
        sd->min = sd->min - 1;
        if (sd->min < 0) sd->min += 60;
     }
   if (sd->sel_obj == sd->digit[4])
     {
        sd->sec = sd->sec - 10;
        if (sd->sec < 0) sd->sec += 60;
     }
   if (sd->sel_obj == sd->digit[5])
     {
        sd->sec = sd->sec - 1;
        if (sd->sec < 0) sd->sec += 60;
     }
   if (sd->sel_obj == sd->am_pm_obj)
     {
        sd->hrs = sd->hrs - 12;
        if (sd->hrs < 0) sd->hrs += 24;
     }
   sd->interval = sd->interval / 1.05;
   ecore_timer_interval_set(sd->spin, sd->interval);
   _time_update(data, EINA_FALSE);
   efl_event_callback_legacy_call(data, ELM_CLOCK_EVENT_CHANGED, NULL);
   return ECORE_CALLBACK_RENEW;

clock_val_down_cancel:
   sd->spin = NULL;

   return ECORE_CALLBACK_CANCEL;
}
void
_forecasts_config_updated(Config_Item *ci)
{
   Eina_List *l;
   char buf[4096];

   if (!forecasts_config)
     return;
   for (l = forecasts_config->instances; l; l = l->next)
     {
        Instance *inst;

        inst = l->data;
        if (inst->ci != ci) continue;
        int area_changed = 0;

        if (inst->area && strcmp(inst->area, inst->ci->code))
          area_changed = 1;

        if (inst->area) eina_stringshare_del(inst->area);
        inst->area = eina_stringshare_add(inst->ci->code);
        _forecasts_converter(inst);

        if (inst->popup) _forecasts_popup_destroy(inst);
        inst->popup = NULL;

        snprintf(buf, sizeof(buf), "%d°%c", inst->condition.temp, inst->units.temp);
        edje_object_part_text_set(inst->forecasts->forecasts_obj, "e.text.temp", buf);

        if (!inst->ci->show_text)
          edje_object_signal_emit(inst->forecasts_obj, "e,state,description,hide", "e");
        else
          edje_object_signal_emit(inst->forecasts_obj, "e,state,description,show", "e");

        //Updating right two icons description
        _right_values_update(inst);
        

        if (area_changed)
          _forecasts_cb_check(inst);

        if (!inst->check_timer)
          inst->check_timer =
            ecore_timer_add(inst->ci->poll_time, _forecasts_cb_check,
                            inst);
        else
          ecore_timer_interval_set(inst->check_timer,
                                   inst->ci->poll_time);

     }
}
Exemple #11
0
/* A timer used to increment the value */
static int _etk_spinner_step_increment_timer_cb(void *data)
{
   Etk_Spinner *spinner;

   if (!(spinner = ETK_SPINNER(data)))
      return 1;

   _etk_spinner_update_value_from_text(spinner);

   ecore_timer_interval_set(spinner->step_timer, (spinner->successive_steps == 0) ? FIRST_DELAY : REPEAT_DELAY);
   _etk_spinner_spin(spinner, ETK_RANGE(spinner)->step_increment);

   return 1;
}
Exemple #12
0
    static Eina_Bool
_weather_cb_check(void *data)
{
    Instance *inst = data;
    EWeather_Data *e_data = eweather_data_current_get(inst->weather);
    _populate(e_data, inst->count);
    _populate(eweather_data_get(inst->weather, 1), (inst->count+1)%15);
    _populate(eweather_data_get(inst->weather, 2), (inst->count+2)%15);

    inst->count++;
    if(inst->count>15)
        inst->count = 0;

    eweather_plugin_update(inst->weather);

    ecore_timer_interval_set(inst->check_timer, 5);
    return EINA_TRUE;
}
void
_mpdule_config_updated (Config_Item * ci)
{
  Eina_List *l;

  if (!mpdule_config)
    return;
  for (l = mpdule_config->instances; l; l = l->next)
    {
      Instance *inst;

      inst = l->data;
      if (inst->ci != ci)
	continue;
      _mpdule_disconnect (inst);
      _mpdule_connect (inst);
      _mpdule_update_song (inst);
      if (inst->update_timer)
	ecore_timer_interval_set (inst->update_timer, ci->poll_time);
      else
	inst->update_timer =
	  ecore_timer_add (ci->poll_time, _mpdule_update_song_cb,
			   inst);
      if (inst->ci->show_popup)
	{
	   if (!inst->popup)
	     {
		_mpdule_popup_create(inst, NULL);
	     }
	}
      else
	{
	   if (inst->popup)
	     {
		_mpdule_popup_destroy(inst);
	     }
	   if (inst->o_popup)
	     {
		evas_object_del(inst->o_popup);
	     }
	}
      break;
    }
}
Exemple #14
0
static Eina_Bool
_ecore_wl_input_cursor_update(void *data)
{
   struct wl_cursor_image *cursor_image;
   struct wl_buffer *buffer;
   Ecore_Wl_Input *input = data;
   unsigned int delay;

   if ((!input) || (!input->cursor)) return EINA_FALSE;

   cursor_image = input->cursor->images[input->cursor_current_index];
   if (!cursor_image) return ECORE_CALLBACK_RENEW;

   if ((buffer = wl_cursor_image_get_buffer(cursor_image)))
     {
        ecore_wl_input_pointer_set(input, input->cursor_surface,
                                   cursor_image->hotspot_x,
                                   cursor_image->hotspot_y);
        wl_surface_attach(input->cursor_surface, buffer, 0, 0);
        wl_surface_damage(input->cursor_surface, 0, 0,
                          cursor_image->width, cursor_image->height);
        wl_surface_commit(input->cursor_surface);

        if ((input->cursor->image_count > 1) && (!input->cursor_frame_cb))
          _ecore_wl_input_cb_pointer_frame(input, NULL, 0);
     }

   if (input->cursor->image_count <= 1)
     return ECORE_CALLBACK_CANCEL;

   delay = cursor_image->delay;
   input->cursor_current_index =
      (input->cursor_current_index + 1) % input->cursor->image_count;

   if (!input->cursor_timer)
     input->cursor_timer =
        ecore_timer_loop_add(delay / 1000.0,
                             _ecore_wl_input_cursor_update, input);
   else
     ecore_timer_interval_set(input->cursor_timer, delay / 1000.0);

   return ECORE_CALLBACK_RENEW;
}
Exemple #15
0
void Timer::setInterval (double seconds)
{
  ecore_timer_interval_set (mETimer, seconds);
}