3 static Ecore_Con_Url *url_up = NULL;
4 static Eina_List *handlers = NULL;
5 static Ecore_Timer *update_timer = NULL;
6 static E_Dialog *dialog = NULL;
7 static char *machid = NULL;
14 ecore_con_url_free(url_up);
20 _delete_cb(void *obj __UNUSED__)
26 _ok_cb(void *data __UNUSED__, E_Dialog *dia __UNUSED__)
28 e_object_del(E_OBJECT(dialog));
29 if (e_config->update.later > 0)
31 e_config->update.later = 0;
32 e_config_save_queue();
37 _bother_me_later_cb(void *data __UNUSED__, E_Dialog *dia __UNUSED__)
39 e_object_del(E_OBJECT(dialog));
40 // 5 * 5 * 1hr === about 1 day limit, so bother-me later will wait
41 // a day in between botherings. botherings reset on e start or restart
42 if (e_config->update.later < 5)
44 e_config->update.later++;
45 e_config_save_queue();
50 _never_tell_me_cb(void *data __UNUSED__, E_Dialog *dia __UNUSED__)
52 if (update_timer) ecore_timer_del(update_timer);
54 e_object_del(E_OBJECT(dialog));
55 e_config->update.check = 0;
56 e_config->update.later = 0;
57 e_config_save_queue();
61 _new_version(const char *ver)
68 man = e_manager_current_get();
70 con = e_container_current_get(man);
73 dialog = e_dialog_new(con, "E", "_update_available");
75 e_object_del_attach_func_set(E_OBJECT(dialog), _delete_cb);
76 e_dialog_button_add(dialog, _("OK"), NULL,
78 e_dialog_button_add(dialog, _("Bother me later"), NULL,
79 _bother_me_later_cb, NULL);
80 e_dialog_button_add(dialog, _("Never tell me"), NULL,
81 _never_tell_me_cb, NULL);
82 e_dialog_button_focus_num(dialog, 1);
83 e_dialog_title_set(dialog, _("Update Notice"));
84 e_dialog_icon_set(dialog, "dialog-warning", 64);
86 snprintf(text, sizeof(text),
87 _("Your enlightenment version is<br>"
88 "not the current latest release.<br>"
89 "The latest version is:<br>"
93 "Please visit www.enlightenment.org<br>"
94 "or update your system packages<br>"
95 "to get a new version."), ver);
96 e_dialog_text_set(dialog, text);
97 e_win_centered_set(dialog->win, 1);
98 e_dialog_show(dialog);
102 _upload_data_cb(void *data __UNUSED__, int ev_type __UNUSED__, void *event)
104 Ecore_Con_Event_Url_Data *ev = event;
105 if (ev->url_con != url_up) return EINA_TRUE;
108 char *txt = alloca(ev->size + 1);
110 memcpy(txt, ev->data, ev->size);
113 if (!strncmp(txt, "OK", 2))
116 else if (!strncmp(txt, "OLD", 3))
118 char *ver = strchr(txt, ' ');
130 _upload_progress_cb(void *data __UNUSED__, int ev_type __UNUSED__, void *event)
132 Ecore_Con_Event_Url_Progress *ev = event;
133 if (ev->url_con != url_up) return EINA_TRUE;
138 _upload_complete_cb(void *data __UNUSED__, int ev_type __UNUSED__, void *event)
140 Ecore_Con_Event_Url_Complete *ev = event;
141 if (ev->url_con != url_up) return EINA_TRUE;
142 if (ev->status != 200)
152 _update_machid_get(void)
158 f = fopen("/etc/machine-id", "r");
159 if (!f) f = fopen("/var/lib/dbus/machine-id", "r");
162 e_user_dir_concat_static(buf, ".machid");
167 len = fread(buf, 1, sizeof(buf) - 1, f);
171 for (c = buf; *c; c++)
179 machid = strdup(buf);
187 e_user_dir_concat_static(buf, ".machid");
192 fwrite("GEN-", 4, 1, f);
193 t = ecore_time_unix_get();
194 fprintf(f, "%1.16f-%i-%i\n", t, rand(), rand());
196 _update_machid_get();
199 // this just is all a wash - just use this
200 machid = strdup("NOIDEAWHATTHEIDOFTHISMACHINEIS");
204 _update_post_generate(char *buf, int size)
206 if (!machid) _update_machid_get();
210 "UPDATE enlightenment %s",
219 if (url_up) _update_done();
220 url_up = ecore_con_url_new("http://www.enlightenment.org/update.php");
223 _update_post_generate(buf, sizeof(buf));
224 ecore_con_url_http_version_set(url_up, ECORE_CON_URL_HTTP_VERSION_1_0);
225 ecore_con_url_post(url_up, buf, strlen(buf), "text/plain");
232 _update_timeout_cb(void *data)
234 double t = 3600.0; // base minimum betwene checks -> 1hr min
235 int later = e_config->update.later;
237 if (e_config->update.check) _update_check();
238 if (update_timer) ecore_timer_del(update_timer);
242 t *= (later * later);
244 update_timer = ecore_timer_add(t, _update_timeout_cb, data);
251 if (ecore_con_url_init())
253 handlers = eina_list_append
254 (handlers, ecore_event_handler_add
255 (ECORE_CON_EVENT_URL_DATA, _upload_data_cb, NULL));
256 handlers = eina_list_append
257 (handlers, ecore_event_handler_add
258 (ECORE_CON_EVENT_URL_PROGRESS, _upload_progress_cb, NULL));
259 handlers = eina_list_append
260 (handlers, ecore_event_handler_add
261 (ECORE_CON_EVENT_URL_COMPLETE, _upload_complete_cb, NULL));
262 if (e_config->update.check)
264 e_config->update.check = 0;
265 _update_timeout_cb(NULL);
266 e_config->update.check = 1;
273 e_update_shutdown(void)
278 ecore_con_url_shutdown();
282 ecore_timer_del(update_timer);
285 if (dialog) e_object_del(E_OBJECT(dialog));