2007-03-02 09:00:20 -08:00
|
|
|
/*
|
2008-07-20 21:12:39 -07:00
|
|
|
* vim:cindent:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
2007-03-02 09:00:20 -08:00
|
|
|
*/
|
2007-06-02 09:35:10 -07:00
|
|
|
#ifndef _FILE_OFFSET_BITS
|
|
|
|
#define _FILE_OFFSET_BITS 64
|
|
|
|
#endif
|
|
|
|
|
2007-06-05 15:12:10 -07:00
|
|
|
#ifdef __linux__
|
2007-06-05 14:52:15 -07:00
|
|
|
#include <features.h>
|
|
|
|
#endif
|
2007-03-02 09:00:20 -08:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/param.h>
|
2007-04-14 09:28:13 -07:00
|
|
|
#include <utime.h>
|
2007-03-02 09:00:20 -08:00
|
|
|
#include <math.h>
|
|
|
|
#include <fnmatch.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <pwd.h>
|
|
|
|
#include <glob.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <Ecore.h>
|
|
|
|
#include <Ecore_Ipc.h>
|
|
|
|
#include <Ecore_File.h>
|
|
|
|
#include <Evas.h>
|
2007-10-31 12:56:59 -07:00
|
|
|
#include <Efreet.h>
|
2007-06-16 09:18:45 -07:00
|
|
|
#include <Eet.h>
|
2008-10-27 15:52:49 -07:00
|
|
|
#include <E_DBus.h>
|
|
|
|
#include <E_Hal.h>
|
2008-10-15 08:12:56 -07:00
|
|
|
#include <eina_stringshare.h>
|
2007-06-16 09:18:45 -07:00
|
|
|
#include "config.h"
|
|
|
|
|
2008-09-23 04:27:34 -07:00
|
|
|
#define E_TYPEDEFS
|
2008-12-17 07:33:43 -08:00
|
|
|
#include "e_config_data.h"
|
2008-09-23 04:27:34 -07:00
|
|
|
#include "e_fm_op.h"
|
|
|
|
#undef E_TYPEDEFS
|
2008-12-17 07:33:43 -08:00
|
|
|
#include "e_config_data.h"
|
2008-07-20 21:12:39 -07:00
|
|
|
#include "e_fm_op.h"
|
|
|
|
|
2007-03-02 09:00:20 -08:00
|
|
|
/* FIXME: things to add to the slave enlightenment_fm process and ipc to e:
|
|
|
|
*
|
2007-04-14 09:33:52 -07:00
|
|
|
* * reporting results of fop's (current status - what has been don, what failed etc.)
|
|
|
|
* * dbus removable device monitoring (in e17 itself now via ecore_dbus - move to enlightenment_fm and ipc removable device add/del and anything else)
|
|
|
|
* * mount/umount of removable devices (to go along with removable device support - put it in here and message back mount success/failure and where it is now mounted - remove from e17 itself)
|
2007-03-02 09:00:20 -08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define DEF_SYNC_NUM 8
|
|
|
|
#define DEF_ROUND_TRIP 0.05
|
|
|
|
#define DEF_ROUND_TRIP_TOLERANCE 0.01
|
2007-05-20 01:41:36 -07:00
|
|
|
#define DEF_MOD_BACKOFF 0.2
|
2007-03-02 09:00:20 -08:00
|
|
|
|
2009-06-06 17:00:41 -07:00
|
|
|
#define E_FM_MOUNT_TIMEOUT 30.0
|
|
|
|
#define E_FM_UNMOUNT_TIMEOUT 60.0
|
|
|
|
#define E_FM_EJECT_TIMEOUT 15.0
|
|
|
|
|
2007-03-02 09:00:20 -08:00
|
|
|
typedef struct _E_Dir E_Dir;
|
|
|
|
typedef struct _E_Fop E_Fop;
|
2007-05-20 01:41:36 -07:00
|
|
|
typedef struct _E_Mod E_Mod;
|
2008-07-20 21:12:39 -07:00
|
|
|
typedef struct _E_Fm_Slave E_Fm_Slave;
|
2008-07-26 06:15:57 -07:00
|
|
|
typedef struct _E_Fm_Task E_Fm_Task;
|
2007-03-02 09:00:20 -08:00
|
|
|
|
|
|
|
struct _E_Dir
|
|
|
|
{
|
|
|
|
int id;
|
|
|
|
const char *dir;
|
|
|
|
Ecore_File_Monitor *mon;
|
|
|
|
int mon_ref;
|
2007-04-14 09:28:13 -07:00
|
|
|
E_Dir *mon_real;
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *fq;
|
2007-03-02 09:00:20 -08:00
|
|
|
Ecore_Idler *idler;
|
|
|
|
int dot_order;
|
|
|
|
int sync;
|
|
|
|
double sync_time;
|
|
|
|
int sync_num;
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *recent_mods;
|
2007-05-20 01:41:36 -07:00
|
|
|
Ecore_Timer *recent_clean;
|
|
|
|
unsigned char cleaning : 1;
|
2007-03-02 09:00:20 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _E_Fop
|
|
|
|
{
|
|
|
|
int id;
|
|
|
|
const char *src;
|
|
|
|
const char *dst;
|
2007-04-14 23:24:07 -07:00
|
|
|
const char *rel;
|
|
|
|
int rel_to;
|
|
|
|
int x, y;
|
2007-04-22 16:32:24 -07:00
|
|
|
unsigned char del_after : 1;
|
|
|
|
unsigned char gone_bad : 1;
|
2007-04-14 09:28:13 -07:00
|
|
|
Ecore_Idler *idler;
|
|
|
|
void *data;
|
2007-03-02 09:00:20 -08:00
|
|
|
};
|
|
|
|
|
2007-05-20 01:41:36 -07:00
|
|
|
struct _E_Mod
|
|
|
|
{
|
|
|
|
const char *path;
|
|
|
|
double timestamp;
|
|
|
|
unsigned char add : 1;
|
|
|
|
unsigned char del : 1;
|
|
|
|
unsigned char mod : 1;
|
|
|
|
unsigned char done : 1;
|
|
|
|
};
|
|
|
|
|
2008-07-20 21:12:39 -07:00
|
|
|
struct _E_Fm_Slave
|
|
|
|
{
|
|
|
|
Ecore_Exe *exe;
|
|
|
|
int id;
|
|
|
|
};
|
|
|
|
|
2008-07-26 06:15:57 -07:00
|
|
|
struct _E_Fm_Task
|
|
|
|
{
|
|
|
|
int id;
|
|
|
|
E_Fm_Op_Type type;
|
|
|
|
E_Fm_Slave *slave;
|
|
|
|
const char *src;
|
|
|
|
const char *dst;
|
|
|
|
const char *rel;
|
|
|
|
int rel_to;
|
|
|
|
int x,y;
|
|
|
|
};
|
|
|
|
|
2007-03-02 09:00:20 -08:00
|
|
|
/* local subsystem functions */
|
|
|
|
static int _e_ipc_init(void);
|
|
|
|
static int _e_ipc_cb_server_add(void *data, int type, void *event);
|
|
|
|
static int _e_ipc_cb_server_del(void *data, int type, void *event);
|
|
|
|
static int _e_ipc_cb_server_data(void *data, int type, void *event);
|
|
|
|
|
2008-07-26 06:15:57 -07:00
|
|
|
static void _e_fm_monitor_start(int id, const char *path);
|
|
|
|
static void _e_fm_monitor_start_try(E_Fm_Task *task);
|
|
|
|
static void _e_fm_monitor_end(int id, const char *path);
|
|
|
|
static E_Fm_Task *_e_fm_task_get(int id);
|
2008-10-22 04:49:33 -07:00
|
|
|
static Eina_List *_e_fm_task_node_get(int id);
|
2008-07-26 06:15:57 -07:00
|
|
|
static void _e_fm_task_remove(E_Fm_Task *task);
|
|
|
|
static void _e_fm_mkdir_try(E_Fm_Task *task);
|
|
|
|
static void _e_fm_mkdir(int id, const char *src, const char *rel, int rel_to, int x, int y);
|
|
|
|
static void _e_fm_handle_error_response(int id, E_Fm_Op_Type type);
|
2008-07-20 21:12:39 -07:00
|
|
|
|
2008-07-26 06:15:57 -07:00
|
|
|
static int _e_client_send(int id, E_Fm_Op_Type type, void *data, int size);
|
2008-07-20 21:12:39 -07:00
|
|
|
|
2008-08-10 19:13:22 -07:00
|
|
|
static int _e_fm_slave_run(E_Fm_Op_Type type, const char *args, int id);
|
2008-07-20 21:12:39 -07:00
|
|
|
static E_Fm_Slave *_e_fm_slave_get(int id);
|
|
|
|
static int _e_fm_slave_send(E_Fm_Slave *slave, E_Fm_Op_Type type, void *data, int size);
|
|
|
|
static int _e_fm_slave_data_cb(void *data, int type, void *event);
|
|
|
|
static int _e_fm_slave_error_cb(void *data, int type, void *event);
|
|
|
|
static int _e_fm_slave_del_cb(void *data, int type, void *event);
|
|
|
|
|
2007-03-02 09:00:20 -08:00
|
|
|
static void _e_cb_file_monitor(void *data, Ecore_File_Monitor *em, Ecore_File_Event event, const char *path);
|
2007-05-20 01:41:36 -07:00
|
|
|
static int _e_cb_recent_clean(void *data);
|
2007-03-02 09:00:20 -08:00
|
|
|
|
2008-07-26 06:15:57 -07:00
|
|
|
static void _e_file_add_mod(E_Dir *ed, const char *path, E_Fm_Op_Type op, int listing);
|
2007-05-20 01:41:36 -07:00
|
|
|
static void _e_file_add(E_Dir *ed, const char *path, int listing);
|
|
|
|
static void _e_file_del(E_Dir *ed, const char *path);
|
|
|
|
static void _e_file_mod(E_Dir *ed, const char *path);
|
|
|
|
static void _e_file_mon_dir_del(E_Dir *ed, const char *path);
|
2007-03-02 09:00:20 -08:00
|
|
|
static void _e_file_mon_list_sync(E_Dir *ed);
|
|
|
|
|
|
|
|
static int _e_cb_file_mon_list_idler(void *data);
|
2007-04-14 09:28:13 -07:00
|
|
|
static int _e_cb_fop_trash_idler(void *data);
|
2008-10-22 04:49:33 -07:00
|
|
|
static char *_e_str_list_remove(Eina_List **list, char *str);
|
2008-08-10 19:13:22 -07:00
|
|
|
static void _e_fm_reorder(const char *file, const char *dst, const char *relative, int after);
|
2007-05-20 01:41:36 -07:00
|
|
|
static void _e_dir_del(E_Dir *ed);
|
2007-03-02 09:00:20 -08:00
|
|
|
|
2008-08-10 19:13:22 -07:00
|
|
|
static const char *_e_prepare_command(E_Fm_Op_Type type, const char *args);
|
2008-07-20 21:12:39 -07:00
|
|
|
|
2007-06-16 09:18:45 -07:00
|
|
|
#ifndef EAPI
|
|
|
|
#define EAPI
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define E_FM_SHARED_DATATYPES
|
|
|
|
#include "e_fm_shared.h"
|
|
|
|
#undef E_FM_SHARED_DATATYPES
|
|
|
|
|
|
|
|
static void _e_dbus_cb_dev_all(void *user_data, void *reply_data, DBusError *error);
|
|
|
|
static void _e_dbus_cb_dev_store(void *user_data, void *reply_data, DBusError *error);
|
|
|
|
static void _e_dbus_cb_dev_vol(void *user_data, void *reply_data, DBusError *error);
|
|
|
|
static void _e_dbus_cb_store_is(void *user_data, void *reply_data, DBusError *error);
|
|
|
|
static void _e_dbus_cb_vol_is(void *user_data, void *reply_data, DBusError *error);
|
|
|
|
static void _e_dbus_cb_dev_add(void *data, DBusMessage *msg);
|
|
|
|
static void _e_dbus_cb_dev_del(void *data, DBusMessage *msg);
|
|
|
|
static void _e_dbus_cb_cap_add(void *data, DBusMessage *msg);
|
2007-10-22 00:38:25 -07:00
|
|
|
static void _e_dbus_cb_prop_modified(void *data, DBusMessage *msg);
|
2007-06-16 09:18:45 -07:00
|
|
|
static void _e_dbus_cb_store_prop(void *data, void *reply_data, DBusError *error);
|
|
|
|
static void _e_dbus_cb_vol_prop(void *data, void *reply_data, DBusError *error);
|
2007-10-22 00:38:25 -07:00
|
|
|
static void _e_dbus_cb_vol_prop_mount_modified(void *data, void *reply_data, DBusError *error);
|
2007-06-16 09:18:45 -07:00
|
|
|
static void _e_dbus_cb_vol_mounted(void *user_data, void *method_return, DBusError *error);
|
|
|
|
static void _e_dbus_cb_vol_unmounted(void *user_data, void *method_return, DBusError *error);
|
2009-06-06 17:00:41 -07:00
|
|
|
static void _e_dbus_cb_vol_unmounted_before_eject(void *user_data, void *method_return, DBusError *error);
|
|
|
|
static int _e_dbus_vb_vol_ejecting_after_unmount(void *data);
|
|
|
|
static void _e_dbus_cb_vol_ejected(void *user_data, void *method_return, DBusError *error);
|
|
|
|
static int _e_dbus_format_error_msg(char **buf, E_Volume *v, DBusError *error);
|
|
|
|
|
|
|
|
static int _e_dbus_vol_mount_timeout(void *data);
|
|
|
|
static int _e_dbus_vol_unmount_timeout(void *data);
|
|
|
|
static int _e_dbus_vol_eject_timeout(void *data);
|
2007-06-16 09:18:45 -07:00
|
|
|
|
|
|
|
EAPI E_Storage *e_storage_add(const char *udi);
|
|
|
|
EAPI void e_storage_del(const char *udi);
|
|
|
|
EAPI E_Storage *e_storage_find(const char *udi);
|
|
|
|
|
2009-06-06 17:00:41 -07:00
|
|
|
EAPI E_Volume *e_volume_add(const char *udi, char first_time);
|
2007-06-16 09:18:45 -07:00
|
|
|
EAPI void e_volume_del(const char *udi);
|
|
|
|
EAPI E_Volume *e_volume_find(const char *udi);
|
|
|
|
|
|
|
|
EAPI void e_volume_mount(E_Volume *v);
|
|
|
|
EAPI void e_volume_unmount(E_Volume *v);
|
2009-06-06 17:00:41 -07:00
|
|
|
EAPI void e_volume_eject(E_Volume *v);
|
2007-06-16 09:18:45 -07:00
|
|
|
|
2007-03-02 09:00:20 -08:00
|
|
|
/* local subsystem globals */
|
|
|
|
static Ecore_Ipc_Server *_e_ipc_server = NULL;
|
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
static Eina_List *_e_dirs = NULL;
|
|
|
|
static Eina_List *_e_fops = NULL;
|
2007-03-02 09:00:20 -08:00
|
|
|
static int _e_sync_num = 0;
|
2008-07-20 21:12:39 -07:00
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
static Eina_List *_e_fm_slaves = NULL;
|
|
|
|
static Eina_List *_e_fm_tasks = NULL;
|
2007-06-16 09:18:45 -07:00
|
|
|
static E_DBus_Connection *_e_dbus_conn = NULL;
|
|
|
|
|
|
|
|
/* contains:
|
|
|
|
* _e_volume_edd
|
|
|
|
* _e_storage_edd
|
|
|
|
* _e_volume_free()
|
|
|
|
* _e_storage_free()
|
|
|
|
* _e_volume_edd_new()
|
|
|
|
* _e_storage_edd_new()
|
|
|
|
* _e_storage_volume_edd_init()
|
|
|
|
* _e_storage_volume_edd_shutdown()
|
|
|
|
*/
|
|
|
|
#define E_FM_SHARED_CODEC
|
|
|
|
#include "e_fm_shared.h"
|
|
|
|
#undef E_FM_SHARED_CODEC
|
|
|
|
|
2007-03-02 09:00:20 -08:00
|
|
|
/* externally accessible functions */
|
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 1; i < argc; i++)
|
|
|
|
{
|
|
|
|
if ((!strcmp(argv[i], "-h")) ||
|
|
|
|
(!strcmp(argv[i], "-help")) ||
|
|
|
|
(!strcmp(argv[i], "--help")))
|
|
|
|
{
|
|
|
|
printf(
|
|
|
|
"This is an internal tool for Enlightenment.\n"
|
|
|
|
"do not use it.\n"
|
|
|
|
);
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ecore_init();
|
2008-10-15 08:12:56 -07:00
|
|
|
eina_stringshare_init();
|
2007-03-02 09:00:20 -08:00
|
|
|
ecore_app_args_set(argc, (const char **)argv);
|
|
|
|
ecore_file_init();
|
|
|
|
ecore_ipc_init();
|
|
|
|
|
2008-07-20 21:12:39 -07:00
|
|
|
ecore_event_handler_add(ECORE_EXE_EVENT_DATA, _e_fm_slave_data_cb, NULL);
|
|
|
|
ecore_event_handler_add(ECORE_EXE_EVENT_ERROR, _e_fm_slave_error_cb, NULL);
|
|
|
|
ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _e_fm_slave_del_cb, NULL);
|
|
|
|
|
2007-06-16 09:18:45 -07:00
|
|
|
_e_storage_volume_edd_init();
|
|
|
|
e_dbus_init();
|
|
|
|
_e_dbus_conn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
|
2007-07-03 08:35:14 -07:00
|
|
|
if (_e_dbus_conn)
|
2007-08-05 16:30:40 -07:00
|
|
|
{
|
|
|
|
e_hal_manager_get_all_devices(_e_dbus_conn, _e_dbus_cb_dev_all, NULL);
|
|
|
|
e_hal_manager_find_device_by_capability(_e_dbus_conn, "storage",
|
|
|
|
_e_dbus_cb_dev_store, NULL);
|
|
|
|
e_hal_manager_find_device_by_capability(_e_dbus_conn, "volume",
|
|
|
|
_e_dbus_cb_dev_vol, NULL);
|
|
|
|
|
|
|
|
e_dbus_signal_handler_add(_e_dbus_conn, "org.freedesktop.Hal",
|
|
|
|
"/org/freedesktop/Hal/Manager",
|
|
|
|
"org.freedesktop.Hal.Manager",
|
|
|
|
"DeviceAdded", _e_dbus_cb_dev_add, NULL);
|
|
|
|
e_dbus_signal_handler_add(_e_dbus_conn, "org.freedesktop.Hal",
|
|
|
|
"/org/freedesktop/Hal/Manager",
|
|
|
|
"org.freedesktop.Hal.Manager",
|
|
|
|
"DeviceRemoved", _e_dbus_cb_dev_del, NULL);
|
|
|
|
e_dbus_signal_handler_add(_e_dbus_conn, "org.freedesktop.Hal",
|
|
|
|
"/org/freedesktop/Hal/Manager",
|
|
|
|
"org.freedesktop.Hal.Manager",
|
|
|
|
"NewCapability", _e_dbus_cb_cap_add, NULL);
|
|
|
|
}
|
2007-06-16 09:18:45 -07:00
|
|
|
|
2007-03-02 09:00:20 -08:00
|
|
|
if (_e_ipc_init()) ecore_main_loop_begin();
|
|
|
|
|
|
|
|
if (_e_ipc_server)
|
|
|
|
{
|
|
|
|
ecore_ipc_server_del(_e_ipc_server);
|
|
|
|
_e_ipc_server = NULL;
|
|
|
|
}
|
|
|
|
|
2007-11-24 05:23:35 -08:00
|
|
|
if (_e_dbus_conn) e_dbus_connection_close(_e_dbus_conn);
|
2007-06-16 09:18:45 -07:00
|
|
|
e_dbus_shutdown();
|
|
|
|
_e_storage_volume_edd_shutdown();
|
|
|
|
|
2007-03-02 09:00:20 -08:00
|
|
|
ecore_ipc_shutdown();
|
|
|
|
ecore_file_shutdown();
|
2008-10-15 08:12:56 -07:00
|
|
|
eina_stringshare_shutdown();
|
2007-03-02 09:00:20 -08:00
|
|
|
ecore_shutdown();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-06-16 09:18:45 -07:00
|
|
|
static void
|
|
|
|
_e_dbus_cb_dev_all(void *user_data, void *reply_data, DBusError *error)
|
|
|
|
{
|
|
|
|
E_Hal_Manager_Get_All_Devices_Return *ret = reply_data;
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *l;
|
|
|
|
char *udi;
|
2007-06-16 09:18:45 -07:00
|
|
|
|
|
|
|
if (!ret || !ret->strings) return;
|
|
|
|
|
|
|
|
if (dbus_error_is_set(error))
|
|
|
|
{
|
|
|
|
dbus_error_free(error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FOREACH(ret->strings, l, udi)
|
2007-06-16 09:18:45 -07:00
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
// printf("DB INIT DEV+: %s\n", udi);
|
2007-07-11 19:20:51 -07:00
|
|
|
e_hal_device_query_capability(_e_dbus_conn, udi, "storage",
|
|
|
|
_e_dbus_cb_store_is, strdup(udi));
|
|
|
|
e_hal_device_query_capability(_e_dbus_conn, udi, "volume",
|
|
|
|
_e_dbus_cb_vol_is, strdup(udi));
|
2007-06-16 09:18:45 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_dbus_cb_dev_store(void *user_data, void *reply_data, DBusError *error)
|
|
|
|
{
|
|
|
|
E_Hal_Manager_Find_Device_By_Capability_Return *ret = reply_data;
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *l;
|
2007-06-16 09:18:45 -07:00
|
|
|
char *device;
|
|
|
|
|
|
|
|
if (!ret || !ret->strings) return;
|
|
|
|
|
|
|
|
if (dbus_error_is_set(error))
|
|
|
|
{
|
|
|
|
dbus_error_free(error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FOREACH(ret->strings, l, device)
|
2007-06-16 09:18:45 -07:00
|
|
|
{
|
2008-09-24 18:34:39 -07:00
|
|
|
// printf("DB STORE+: %s\n", device);
|
2007-06-16 09:18:45 -07:00
|
|
|
e_storage_add(device);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_dbus_cb_dev_vol(void *user_data, void *reply_data, DBusError *error)
|
|
|
|
{
|
|
|
|
E_Hal_Manager_Find_Device_By_Capability_Return *ret = reply_data;
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *l;
|
2007-06-16 09:18:45 -07:00
|
|
|
char *device;
|
|
|
|
|
|
|
|
if (!ret || !ret->strings) return;
|
|
|
|
|
|
|
|
if (dbus_error_is_set(error))
|
|
|
|
{
|
|
|
|
dbus_error_free(error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FOREACH(ret->strings, l, device)
|
2007-06-16 09:18:45 -07:00
|
|
|
{
|
2008-09-24 18:34:39 -07:00
|
|
|
// printf("DB VOL+: %s\n", device);
|
2009-06-06 17:00:41 -07:00
|
|
|
e_volume_add(device, 1);
|
2007-06-16 09:18:45 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_dbus_cb_store_is(void *user_data, void *reply_data, DBusError *error)
|
|
|
|
{
|
|
|
|
char *udi = user_data;
|
|
|
|
E_Hal_Device_Query_Capability_Return *ret = reply_data;
|
|
|
|
|
|
|
|
if (dbus_error_is_set(error))
|
|
|
|
{
|
|
|
|
dbus_error_free(error);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret && ret->boolean)
|
|
|
|
{
|
2008-09-24 18:34:39 -07:00
|
|
|
// printf("DB STORE IS+: %s\n", udi);
|
2007-06-16 09:18:45 -07:00
|
|
|
e_storage_add(udi);
|
|
|
|
}
|
|
|
|
|
|
|
|
error:
|
|
|
|
free(udi);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_dbus_cb_vol_is(void *user_data, void *reply_data, DBusError *error)
|
|
|
|
{
|
|
|
|
char *udi = user_data;
|
|
|
|
E_Hal_Device_Query_Capability_Return *ret = reply_data;
|
2008-01-10 23:33:57 -08:00
|
|
|
|
2007-06-16 09:18:45 -07:00
|
|
|
if (dbus_error_is_set(error))
|
|
|
|
{
|
|
|
|
dbus_error_free(error);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret && ret->boolean)
|
|
|
|
{
|
2008-09-24 18:34:39 -07:00
|
|
|
// printf("DB VOL IS+: %s\n", udi);
|
2009-06-06 17:00:41 -07:00
|
|
|
e_volume_add(udi, 0);
|
2007-06-16 09:18:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
error:
|
|
|
|
free(udi);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_dbus_cb_dev_add(void *data, DBusMessage *msg)
|
|
|
|
{
|
|
|
|
DBusError err;
|
2008-11-14 17:26:20 -08:00
|
|
|
char *udi = NULL;
|
2007-06-16 09:18:45 -07:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
dbus_error_init(&err);
|
|
|
|
dbus_message_get_args(msg, &err, DBUS_TYPE_STRING, &udi, DBUS_TYPE_INVALID);
|
2008-11-14 17:26:20 -08:00
|
|
|
if (!udi) return;
|
2008-09-24 18:34:39 -07:00
|
|
|
// printf("DB DEV+: %s\n", udi);
|
2007-06-16 09:18:45 -07:00
|
|
|
ret = e_hal_device_query_capability(_e_dbus_conn, udi, "storage",
|
|
|
|
_e_dbus_cb_store_is, strdup(udi));
|
|
|
|
e_hal_device_query_capability(_e_dbus_conn, udi, "volume",
|
|
|
|
_e_dbus_cb_vol_is, strdup(udi));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_dbus_cb_dev_del(void *data, DBusMessage *msg)
|
|
|
|
{
|
|
|
|
DBusError err;
|
|
|
|
char *udi;
|
|
|
|
|
|
|
|
dbus_error_init(&err);
|
|
|
|
|
|
|
|
dbus_message_get_args(msg,
|
|
|
|
&err, DBUS_TYPE_STRING,
|
|
|
|
&udi, DBUS_TYPE_INVALID);
|
2008-09-24 18:34:39 -07:00
|
|
|
// printf("DB DEV-: %s\n", udi);
|
2007-06-16 09:18:45 -07:00
|
|
|
e_storage_del(udi);
|
|
|
|
e_volume_del(udi);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_dbus_cb_cap_add(void *data, DBusMessage *msg)
|
|
|
|
{
|
|
|
|
DBusError err;
|
|
|
|
char *udi, *capability;
|
|
|
|
|
|
|
|
dbus_error_init(&err);
|
|
|
|
|
|
|
|
dbus_message_get_args(msg,
|
|
|
|
&err, DBUS_TYPE_STRING,
|
|
|
|
&udi, DBUS_TYPE_STRING,
|
|
|
|
&capability, DBUS_TYPE_INVALID);
|
|
|
|
if (!strcmp(capability, "storage"))
|
|
|
|
{
|
2008-09-24 18:34:39 -07:00
|
|
|
// printf("DB STORE CAP+: %s\n", udi);
|
2007-06-16 09:18:45 -07:00
|
|
|
e_storage_add(udi);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-22 00:38:25 -07:00
|
|
|
static void
|
|
|
|
_e_dbus_cb_prop_modified(void *data, DBusMessage *msg)
|
|
|
|
{
|
|
|
|
E_Volume *v;
|
|
|
|
DBusMessageIter iter, sub, subsub;
|
|
|
|
struct {
|
|
|
|
const char *name;
|
|
|
|
int added;
|
|
|
|
int removed;
|
|
|
|
} prop;
|
|
|
|
int num_changes = 0, i;
|
|
|
|
|
|
|
|
if (!(v = data)) return;
|
|
|
|
|
|
|
|
if (dbus_message_get_error_name(msg))
|
|
|
|
{
|
|
|
|
printf("DBUS ERROR: %s\n", dbus_message_get_error_name(msg));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!dbus_message_iter_init(msg, &iter)) return;
|
|
|
|
|
|
|
|
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INT32) return;
|
|
|
|
dbus_message_iter_get_basic(&iter, &num_changes);
|
|
|
|
if (num_changes == 0) return;
|
|
|
|
|
|
|
|
dbus_message_iter_next(&iter);
|
|
|
|
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY) return;
|
|
|
|
dbus_message_iter_recurse(&iter, &sub);
|
|
|
|
|
|
|
|
for (i = 0; i < num_changes; i++, dbus_message_iter_next(&sub))
|
|
|
|
{
|
|
|
|
dbus_message_iter_recurse(&sub, &subsub);
|
|
|
|
|
|
|
|
if (dbus_message_iter_get_arg_type(&subsub) != DBUS_TYPE_STRING) break;
|
|
|
|
dbus_message_iter_get_basic(&subsub, &(prop.name));
|
|
|
|
if (!strcmp(prop.name, "volume.mount_point"))
|
|
|
|
{
|
|
|
|
e_hal_device_get_all_properties(_e_dbus_conn, v->udi,
|
|
|
|
_e_dbus_cb_vol_prop_mount_modified,
|
|
|
|
v);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dbus_message_iter_next(&subsub);
|
|
|
|
dbus_message_iter_next(&subsub);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-16 09:18:45 -07:00
|
|
|
static void
|
|
|
|
_e_dbus_cb_store_prop(void *data, void *reply_data, DBusError *error)
|
|
|
|
{
|
|
|
|
E_Storage *s = data;
|
|
|
|
E_Hal_Properties *ret = reply_data;
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
if (!ret) goto error;
|
2007-10-22 00:38:25 -07:00
|
|
|
|
2007-06-16 09:18:45 -07:00
|
|
|
if (dbus_error_is_set(error))
|
|
|
|
{
|
|
|
|
dbus_error_free(error);
|
|
|
|
goto error;
|
|
|
|
}
|
2007-10-22 00:38:25 -07:00
|
|
|
|
2007-06-16 09:18:45 -07:00
|
|
|
s->bus = e_hal_property_string_get(ret, "storage.bus", &err);
|
|
|
|
if (err) goto error;
|
|
|
|
s->drive_type = e_hal_property_string_get(ret, "storage.drive_type", &err);
|
|
|
|
if (err) goto error;
|
|
|
|
s->model = e_hal_property_string_get(ret, "storage.model", &err);
|
|
|
|
if (err) goto error;
|
|
|
|
s->vendor = e_hal_property_string_get(ret, "storage.vendor", &err);
|
|
|
|
if (err) goto error;
|
|
|
|
s->serial = e_hal_property_string_get(ret, "storage.serial", &err);
|
2007-10-22 00:38:25 -07:00
|
|
|
// if (err) goto error;
|
|
|
|
if (err) printf("Error getting serial for %s\n", s->udi);
|
|
|
|
|
2007-06-16 09:18:45 -07:00
|
|
|
s->removable = e_hal_property_bool_get(ret, "storage.removable", &err);
|
|
|
|
|
|
|
|
if (s->removable)
|
|
|
|
{
|
|
|
|
s->media_available = e_hal_property_bool_get(ret, "storage.removable.media_available", &err);
|
|
|
|
s->media_size = e_hal_property_uint64_get(ret, "storage.removable.media_size", &err);
|
|
|
|
}
|
|
|
|
|
|
|
|
s->requires_eject = e_hal_property_bool_get(ret, "storage.requires_eject", &err);
|
|
|
|
s->hotpluggable = e_hal_property_bool_get(ret, "storage.hotpluggable", &err);
|
|
|
|
s->media_check_enabled = e_hal_property_bool_get(ret, "storage.media_check_enabled", &err);
|
|
|
|
|
|
|
|
s->icon.drive = e_hal_property_string_get(ret, "storage.icon.drive", &err);
|
|
|
|
s->icon.volume = e_hal_property_string_get(ret, "storage.icon.volume", &err);
|
|
|
|
|
2008-09-24 18:34:39 -07:00
|
|
|
// printf("++STO:\n udi: %s\n bus: %s\n drive_type: %s\n model: %s\n vendor: %s\n serial: %s\n icon.drive: %s\n icon.volume: %s\n\n", s->udi, s->bus, s->drive_type, s->model, s->vendor, s->serial, s->icon.drive, s->icon.volume);
|
2007-06-16 09:18:45 -07:00
|
|
|
s->validated = 1;
|
|
|
|
{
|
|
|
|
void *msg_data;
|
|
|
|
int msg_size;
|
|
|
|
|
|
|
|
msg_data = eet_data_descriptor_encode(_e_storage_edd, s, &msg_size);
|
|
|
|
if (msg_data)
|
|
|
|
{
|
|
|
|
ecore_ipc_server_send(_e_ipc_server,
|
|
|
|
6/*E_IPC_DOMAIN_FM*/,
|
2008-07-26 06:15:57 -07:00
|
|
|
E_FM_OP_STORAGE_ADD,
|
2007-06-16 09:18:45 -07:00
|
|
|
0, 0, 0, msg_data, msg_size);
|
|
|
|
free(msg_data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
|
|
|
|
error:
|
2008-09-24 18:34:39 -07:00
|
|
|
// printf("ERR %s\n", s->udi);
|
2007-06-16 09:18:45 -07:00
|
|
|
e_storage_del(s->udi);
|
|
|
|
}
|
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
static Eina_List *_e_stores = NULL;
|
2007-06-16 09:18:45 -07:00
|
|
|
|
|
|
|
EAPI E_Storage *
|
|
|
|
e_storage_add(const char *udi)
|
|
|
|
{
|
|
|
|
E_Storage *s;
|
|
|
|
|
|
|
|
if (!udi) return NULL;
|
|
|
|
if (e_storage_find(udi)) return NULL;
|
|
|
|
s = calloc(1, sizeof(E_Storage));
|
|
|
|
if (!s) return NULL;
|
|
|
|
s->udi = strdup(udi);
|
2008-10-22 04:49:33 -07:00
|
|
|
_e_stores = eina_list_append(_e_stores, s);
|
2007-06-16 09:18:45 -07:00
|
|
|
e_hal_device_get_all_properties(_e_dbus_conn, s->udi,
|
|
|
|
_e_dbus_cb_store_prop, s);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
e_storage_del(const char *udi)
|
|
|
|
{
|
|
|
|
E_Storage *s;
|
|
|
|
|
|
|
|
s = e_storage_find(udi);
|
|
|
|
if (!s) return;
|
|
|
|
if (s->validated)
|
|
|
|
{
|
2008-09-24 18:34:39 -07:00
|
|
|
// printf("--STO %s\n", s->udi);
|
2007-06-16 09:18:45 -07:00
|
|
|
ecore_ipc_server_send(_e_ipc_server,
|
|
|
|
6/*E_IPC_DOMAIN_FM*/,
|
2008-07-26 06:15:57 -07:00
|
|
|
E_FM_OP_STORAGE_DEL,
|
2007-06-16 09:18:45 -07:00
|
|
|
0, 0, 0, s->udi, strlen(s->udi) + 1);
|
|
|
|
}
|
2008-10-22 04:49:33 -07:00
|
|
|
_e_stores = eina_list_remove(_e_stores, s);
|
2007-06-16 09:18:45 -07:00
|
|
|
_e_storage_free(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
E_Storage *
|
|
|
|
e_storage_find(const char *udi)
|
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l;
|
2009-08-21 08:08:49 -07:00
|
|
|
E_Storage *s;
|
2007-06-16 09:18:45 -07:00
|
|
|
|
2009-08-21 08:08:49 -07:00
|
|
|
EINA_LIST_FOREACH(_e_stores, l, s)
|
2007-06-16 09:18:45 -07:00
|
|
|
{
|
|
|
|
if (!strcmp(udi, s->udi)) return s;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_dbus_cb_vol_prop(void *data, void *reply_data, DBusError *error)
|
|
|
|
{
|
|
|
|
E_Volume *v = data;
|
|
|
|
E_Storage *s = NULL;
|
|
|
|
E_Hal_Device_Get_All_Properties_Return *ret = reply_data;
|
|
|
|
int err = 0;
|
|
|
|
char *str = NULL;
|
|
|
|
|
|
|
|
if (!ret) goto error;
|
|
|
|
if (dbus_error_is_set(error))
|
|
|
|
{
|
|
|
|
dbus_error_free(error);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* skip volumes with volume.ignore set */
|
|
|
|
if (e_hal_property_bool_get(ret, "volume.ignore", &err) || err)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
/* skip volumes that aren't filesystems */
|
|
|
|
str = e_hal_property_string_get(ret, "volume.fsusage", &err);
|
|
|
|
if (err || !str) goto error;
|
|
|
|
if (strcmp(str, "filesystem")) goto error;
|
|
|
|
free(str);
|
|
|
|
str = NULL;
|
|
|
|
|
|
|
|
v->uuid = e_hal_property_string_get(ret, "volume.uuid", &err);
|
|
|
|
if (err) goto error;
|
|
|
|
|
|
|
|
v->label = e_hal_property_string_get(ret, "volume.label", &err);
|
|
|
|
// if (err) goto error;
|
|
|
|
|
|
|
|
v->fstype = e_hal_property_string_get(ret, "volume.fstype", &err);
|
|
|
|
// if (err) goto error;
|
2007-10-22 00:38:25 -07:00
|
|
|
|
|
|
|
v->size = e_hal_property_uint64_get(ret, "volume.size", &err);
|
2007-06-16 09:18:45 -07:00
|
|
|
|
|
|
|
v->mounted = e_hal_property_bool_get(ret, "volume.is_mounted", &err);
|
|
|
|
if (err) goto error;
|
|
|
|
|
|
|
|
v->partition = e_hal_property_bool_get(ret, "volume.is_partition", &err);
|
|
|
|
if (err) goto error;
|
2007-10-22 00:38:25 -07:00
|
|
|
|
2007-06-16 09:18:45 -07:00
|
|
|
v->mount_point = e_hal_property_string_get(ret, "volume.mount_point", &err);
|
|
|
|
if (err) goto error;
|
|
|
|
|
|
|
|
if (v->partition)
|
|
|
|
{
|
2007-10-22 00:38:25 -07:00
|
|
|
v->partition_number = e_hal_property_int_get(ret, "volume.partition.number", NULL);
|
|
|
|
v->partition_label = e_hal_property_string_get(ret, "volume.partition.label", NULL);
|
2007-06-16 09:18:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
v->parent = e_hal_property_string_get(ret, "info.parent", &err);
|
|
|
|
if ((!err) && (v->parent))
|
|
|
|
{
|
|
|
|
s = e_storage_find(v->parent);
|
|
|
|
if (s)
|
|
|
|
{
|
|
|
|
v->storage = s;
|
2008-10-22 04:49:33 -07:00
|
|
|
s->volumes = eina_list_append(s->volumes, v);
|
2007-06-16 09:18:45 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-24 18:34:39 -07:00
|
|
|
// printf("++VOL:\n udi: %s\n uuid: %s\n fstype: %s\n size: %llu\n label: %s\n partition: %d\n partition_number: %d\n partition_label: %s\n mounted: %d\n mount_point: %s\n", v->udi, v->uuid, v->fstype, v->size, v->label, v->partition, v->partition_number, v->partition ? v->partition_label : "(not a partition)", v->mounted, v->mount_point);
|
|
|
|
// if (s) printf(" for storage: %s\n", s->udi);
|
|
|
|
// else printf(" storage unknown\n");
|
2007-06-16 09:18:45 -07:00
|
|
|
v->validated = 1;
|
|
|
|
{
|
|
|
|
void *msg_data;
|
|
|
|
int msg_size;
|
|
|
|
|
|
|
|
msg_data = eet_data_descriptor_encode(_e_volume_edd, v, &msg_size);
|
|
|
|
if (msg_data)
|
|
|
|
{
|
|
|
|
ecore_ipc_server_send(_e_ipc_server,
|
|
|
|
6/*E_IPC_DOMAIN_FM*/,
|
2008-07-26 06:15:57 -07:00
|
|
|
E_FM_OP_VOLUME_ADD,
|
2007-06-16 09:18:45 -07:00
|
|
|
0, 0, 0, msg_data, msg_size);
|
|
|
|
free(msg_data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
|
|
|
|
error:
|
|
|
|
e_volume_del(v->udi);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-06-06 17:00:41 -07:00
|
|
|
static int
|
|
|
|
_e_dbus_format_error_msg(char **buf, E_Volume *v, DBusError *error)
|
|
|
|
{
|
|
|
|
int size, vu, vm, en;
|
|
|
|
char *tmp;
|
|
|
|
|
|
|
|
vu = strlen(v->udi) + 1;
|
|
|
|
vm = strlen(v->mount_point) + 1;
|
|
|
|
en = strlen(error->name) + 1;
|
|
|
|
size = vu + vm + en + strlen(error->message) + 1;
|
|
|
|
tmp = *buf = malloc(size);
|
|
|
|
|
|
|
|
strcpy(tmp, v->udi);
|
|
|
|
strcpy(tmp += vu, v->mount_point);
|
|
|
|
strcpy(tmp += vm, error->name);
|
|
|
|
strcpy(tmp += en, error->message);
|
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2007-10-22 00:38:25 -07:00
|
|
|
static void
|
|
|
|
_e_dbus_cb_vol_prop_mount_modified(void *data, void *reply_data, DBusError *error)
|
|
|
|
{
|
|
|
|
E_Volume *v = data;
|
|
|
|
E_Hal_Device_Get_All_Properties_Return *ret = reply_data;
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
if (!ret) return;
|
|
|
|
if (dbus_error_is_set(error))
|
|
|
|
{
|
2009-06-06 17:00:41 -07:00
|
|
|
char *buf;
|
|
|
|
int size;
|
|
|
|
|
|
|
|
size = _e_dbus_format_error_msg(&buf, v, error);
|
|
|
|
if (v->mounted)
|
|
|
|
ecore_ipc_server_send(_e_ipc_server, 6/*E_IPC_DOMAIN_FM*/, E_FM_OP_UNMOUNT_ERROR,
|
|
|
|
0, 0, 0, buf, size);
|
|
|
|
else
|
|
|
|
ecore_ipc_server_send(_e_ipc_server, 6/*E_IPC_DOMAIN_FM*/, E_FM_OP_MOUNT_ERROR,
|
|
|
|
0, 0, 0, buf, size);
|
2007-10-22 00:38:25 -07:00
|
|
|
dbus_error_free(error);
|
2009-06-06 17:00:41 -07:00
|
|
|
free(buf);
|
2007-10-22 00:38:25 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
v->mounted = e_hal_property_bool_get(ret, "volume.is_mounted", &err);
|
|
|
|
if (err) printf("HAL Error : can't get volume.is_mounted property");
|
|
|
|
|
|
|
|
if (v->mount_point) free(v->mount_point);
|
|
|
|
v->mount_point = e_hal_property_string_get(ret, "volume.mount_point", &err);
|
|
|
|
if (err) printf("HAL Error : can't get volume.is_mount_point property");
|
|
|
|
|
2008-09-24 18:34:39 -07:00
|
|
|
// printf("**VOL udi: %s mount_point: %s mounted: %d\n", v->udi, v->mount_point, v->mounted);
|
2007-10-22 00:38:25 -07:00
|
|
|
{
|
|
|
|
char *buf;
|
|
|
|
int size;
|
|
|
|
|
|
|
|
size = strlen(v->udi) + 1 + strlen(v->mount_point) + 1;
|
|
|
|
buf = alloca(size);
|
|
|
|
strcpy(buf, v->udi);
|
|
|
|
strcpy(buf + strlen(buf) + 1, v->mount_point);
|
|
|
|
if (v->mounted)
|
|
|
|
ecore_ipc_server_send(_e_ipc_server,
|
|
|
|
6/*E_IPC_DOMAIN_FM*/,
|
2008-07-26 06:15:57 -07:00
|
|
|
E_FM_OP_MOUNT_DONE,
|
2007-10-22 00:38:25 -07:00
|
|
|
0, 0, 0, buf, size);
|
|
|
|
else
|
|
|
|
ecore_ipc_server_send(_e_ipc_server,
|
|
|
|
6/*E_IPC_DOMAIN_FM*/,
|
2008-07-26 06:15:57 -07:00
|
|
|
E_FM_OP_UNMOUNT_DONE,
|
2007-10-22 00:38:25 -07:00
|
|
|
0, 0, 0, buf, size);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
static Eina_List *_e_vols = NULL;
|
2007-06-16 09:18:45 -07:00
|
|
|
|
|
|
|
EAPI E_Volume *
|
2009-06-06 17:00:41 -07:00
|
|
|
e_volume_add(const char *udi, char first_time)
|
2007-06-16 09:18:45 -07:00
|
|
|
{
|
|
|
|
E_Volume *v;
|
|
|
|
|
|
|
|
if (!udi) return NULL;
|
|
|
|
if (e_volume_find(udi)) return NULL;
|
|
|
|
v = calloc(1, sizeof(E_Volume));
|
|
|
|
if (!v) return NULL;
|
2008-09-24 18:34:39 -07:00
|
|
|
// printf("VOL+ %s\n", udi);
|
2007-06-16 09:18:45 -07:00
|
|
|
v->udi = strdup(udi);
|
2009-03-02 17:04:09 -08:00
|
|
|
v->icon = NULL;
|
2009-06-06 17:00:41 -07:00
|
|
|
v->first_time = first_time;
|
2008-10-22 04:49:33 -07:00
|
|
|
_e_vols = eina_list_append(_e_vols, v);
|
2007-06-16 09:18:45 -07:00
|
|
|
e_hal_device_get_all_properties(_e_dbus_conn, v->udi,
|
|
|
|
_e_dbus_cb_vol_prop, v);
|
2007-10-22 00:38:25 -07:00
|
|
|
v->prop_handler = e_dbus_signal_handler_add(_e_dbus_conn, "org.freedesktop.Hal",
|
|
|
|
udi,
|
|
|
|
"org.freedesktop.Hal.Device",
|
|
|
|
"PropertyModified", _e_dbus_cb_prop_modified, v);
|
2009-06-06 17:00:41 -07:00
|
|
|
v->guard = NULL;
|
|
|
|
|
2007-06-16 09:18:45 -07:00
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
e_volume_del(const char *udi)
|
|
|
|
{
|
|
|
|
E_Volume *v;
|
|
|
|
|
|
|
|
v = e_volume_find(udi);
|
|
|
|
if (!v) return;
|
2009-06-06 17:00:41 -07:00
|
|
|
if (v->guard)
|
|
|
|
{
|
|
|
|
ecore_timer_del(v->guard);
|
|
|
|
v->guard = NULL;
|
|
|
|
}
|
2007-10-22 00:38:25 -07:00
|
|
|
if (v->prop_handler) e_dbus_signal_handler_del(_e_dbus_conn, v->prop_handler);
|
2007-06-16 09:18:45 -07:00
|
|
|
if (v->validated)
|
|
|
|
{
|
2008-09-24 18:34:39 -07:00
|
|
|
// printf("--VOL %s\n", v->udi);
|
2007-06-16 09:18:45 -07:00
|
|
|
/* FIXME: send event of storage volume (disk) removed */
|
|
|
|
ecore_ipc_server_send(_e_ipc_server,
|
|
|
|
6/*E_IPC_DOMAIN_FM*/,
|
2008-07-26 06:15:57 -07:00
|
|
|
E_FM_OP_VOLUME_DEL,
|
2007-06-16 09:18:45 -07:00
|
|
|
0, 0, 0, v->udi, strlen(v->udi) + 1);
|
|
|
|
}
|
2008-10-22 04:49:33 -07:00
|
|
|
_e_vols = eina_list_remove(_e_vols, v);
|
2007-06-16 09:18:45 -07:00
|
|
|
_e_volume_free(v);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI E_Volume *
|
|
|
|
e_volume_find(const char *udi)
|
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l;
|
2009-08-21 08:08:49 -07:00
|
|
|
E_Volume *v;
|
2007-06-16 09:18:45 -07:00
|
|
|
|
2009-08-21 08:08:49 -07:00
|
|
|
EINA_LIST_FOREACH(_e_vols, l, v)
|
2007-06-16 09:18:45 -07:00
|
|
|
{
|
|
|
|
if (!strcmp(udi, v->udi)) return v;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-06-06 17:00:41 -07:00
|
|
|
static int
|
|
|
|
_e_dbus_vol_mount_timeout(void *data)
|
|
|
|
{
|
|
|
|
E_Volume *v = data;
|
|
|
|
DBusError error;
|
|
|
|
char *buf;
|
|
|
|
int size;
|
|
|
|
|
|
|
|
v->guard = NULL;
|
|
|
|
dbus_pending_call_cancel(v->op);
|
|
|
|
error.name = "org.enlightenment.fm2.MountTimeout";
|
|
|
|
error.message = "Unable to mount the volume with specified time-out.";
|
|
|
|
size = _e_dbus_format_error_msg(&buf, v, &error);
|
|
|
|
ecore_ipc_server_send(_e_ipc_server, 6/*E_IPC_DOMAIN_FM*/, E_FM_OP_MOUNT_ERROR,
|
|
|
|
0, 0, 0, buf, size);
|
|
|
|
free(buf);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-06-16 09:18:45 -07:00
|
|
|
static void
|
|
|
|
_e_dbus_cb_vol_mounted(void *user_data, void *method_return, DBusError *error)
|
|
|
|
{
|
|
|
|
E_Volume *v = user_data;
|
|
|
|
char *buf;
|
|
|
|
int size;
|
|
|
|
|
2009-06-06 17:00:41 -07:00
|
|
|
if (v->guard)
|
|
|
|
{
|
|
|
|
ecore_timer_del(v->guard);
|
|
|
|
v->guard = NULL;
|
|
|
|
}
|
|
|
|
|
2007-10-22 00:38:25 -07:00
|
|
|
if (dbus_error_is_set(error))
|
|
|
|
{
|
2009-06-06 17:00:41 -07:00
|
|
|
size = _e_dbus_format_error_msg(&buf, v, error);
|
|
|
|
ecore_ipc_server_send(_e_ipc_server, 6/*E_IPC_DOMAIN_FM*/, E_FM_OP_MOUNT_ERROR,
|
|
|
|
0, 0, 0, buf, size);
|
|
|
|
dbus_error_free(error);
|
|
|
|
free(buf);
|
|
|
|
return;
|
2007-10-22 00:38:25 -07:00
|
|
|
}
|
2009-06-06 17:00:41 -07:00
|
|
|
|
|
|
|
/*
|
2007-06-16 09:18:45 -07:00
|
|
|
v->mounted = 1;
|
2008-09-24 18:34:39 -07:00
|
|
|
// printf("MOUNT: %s from %s\n", v->udi, v->mount_point);
|
2007-06-16 09:18:45 -07:00
|
|
|
size = strlen(v->udi) + 1 + strlen(v->mount_point) + 1;
|
|
|
|
buf = alloca(size);
|
|
|
|
strcpy(buf, v->udi);
|
|
|
|
strcpy(buf + strlen(buf) + 1, v->mount_point);
|
|
|
|
ecore_ipc_server_send(_e_ipc_server,
|
2009-06-06 17:00:41 -07:00
|
|
|
6/*E_IPC_DOMAIN_FM*//*,
|
2008-07-26 06:15:57 -07:00
|
|
|
E_FM_OP_MOUNT_DONE,
|
2007-06-16 09:18:45 -07:00
|
|
|
0, 0, 0, buf, size);
|
2009-06-06 17:00:41 -07:00
|
|
|
*/
|
2007-06-16 09:18:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
e_volume_mount(E_Volume *v)
|
|
|
|
{
|
2007-10-22 00:38:25 -07:00
|
|
|
char buf[256];
|
2007-06-16 09:18:45 -07:00
|
|
|
char *mount_point;
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *opt = NULL;
|
2007-10-22 00:38:25 -07:00
|
|
|
|
2009-06-06 17:00:41 -07:00
|
|
|
if (!v || v->guard || !v->mount_point || strncmp(v->mount_point, "/media/", 7))
|
2007-10-22 00:38:25 -07:00
|
|
|
return;
|
|
|
|
|
|
|
|
mount_point = v->mount_point + 7;
|
2008-09-24 18:34:39 -07:00
|
|
|
// printf("mount %s %s [fs type = %s]\n", v->udi, v->mount_point, v->fstype);
|
2007-10-22 00:38:25 -07:00
|
|
|
|
|
|
|
if ((!strcmp(v->fstype, "vfat")) || (!strcmp(v->fstype, "ntfs"))
|
|
|
|
// || (!strcmp(v->fstype, "iso9660")) || (!strcmp(v->fstype, "udf"))
|
|
|
|
)
|
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "uid=%i", (int)getuid());
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
opt = eina_list_append(opt, buf);
|
2007-10-22 00:38:25 -07:00
|
|
|
}
|
2009-06-06 17:00:41 -07:00
|
|
|
v->guard = ecore_timer_add(E_FM_MOUNT_TIMEOUT, _e_dbus_vol_mount_timeout, v);
|
|
|
|
v->op = e_hal_device_volume_mount(_e_dbus_conn, v->udi, mount_point,
|
|
|
|
v->fstype, opt, _e_dbus_cb_vol_mounted, v);
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
opt = eina_list_free(opt);
|
2007-06-16 09:18:45 -07:00
|
|
|
}
|
|
|
|
|
2009-06-06 17:00:41 -07:00
|
|
|
static int
|
|
|
|
_e_dbus_vol_unmount_timeout(void *data)
|
|
|
|
{
|
|
|
|
E_Volume *v = data;
|
|
|
|
DBusError error;
|
|
|
|
char *buf;
|
|
|
|
int size;
|
|
|
|
|
|
|
|
v->guard = NULL;
|
|
|
|
dbus_pending_call_cancel(v->op);
|
|
|
|
error.name = "org.enlightenment.fm2.UnmountTimeout";
|
|
|
|
error.message = "Unable to unmount the volume with specified time-out.";
|
|
|
|
size = _e_dbus_format_error_msg(&buf, v, &error);
|
|
|
|
ecore_ipc_server_send(_e_ipc_server, 6/*E_IPC_DOMAIN_FM*/, E_FM_OP_UNMOUNT_ERROR,
|
|
|
|
0, 0, 0, buf, size);
|
|
|
|
free(buf);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-06-16 09:18:45 -07:00
|
|
|
static void
|
|
|
|
_e_dbus_cb_vol_unmounted(void *user_data, void *method_return, DBusError *error)
|
|
|
|
{
|
|
|
|
E_Volume *v = user_data;
|
|
|
|
char *buf;
|
|
|
|
int size;
|
|
|
|
|
2009-06-06 17:00:41 -07:00
|
|
|
if (v->guard)
|
|
|
|
{
|
|
|
|
ecore_timer_del(v->guard);
|
|
|
|
v->guard = NULL;
|
|
|
|
}
|
|
|
|
|
2007-10-22 00:38:25 -07:00
|
|
|
if (dbus_error_is_set(error))
|
|
|
|
{
|
2009-06-06 17:00:41 -07:00
|
|
|
size = _e_dbus_format_error_msg(&buf, v, error);
|
|
|
|
ecore_ipc_server_send(_e_ipc_server, 6/*E_IPC_DOMAIN_FM*/, E_FM_OP_UNMOUNT_ERROR,
|
|
|
|
0, 0, 0, buf, size);
|
|
|
|
dbus_error_free(error);
|
|
|
|
free(buf);
|
|
|
|
return;
|
2007-10-22 00:38:25 -07:00
|
|
|
}
|
2009-06-06 17:00:41 -07:00
|
|
|
|
|
|
|
/*
|
2007-06-16 09:18:45 -07:00
|
|
|
v->mounted = 0;
|
2008-09-24 18:34:39 -07:00
|
|
|
// printf("UNMOUNT: %s from %s\n", v->udi, v->mount_point);
|
2007-06-16 09:18:45 -07:00
|
|
|
size = strlen(v->udi) + 1 + strlen(v->mount_point) + 1;
|
|
|
|
buf = alloca(size);
|
|
|
|
strcpy(buf, v->udi);
|
|
|
|
strcpy(buf + strlen(buf) + 1, v->mount_point);
|
|
|
|
ecore_ipc_server_send(_e_ipc_server,
|
2009-06-06 17:00:41 -07:00
|
|
|
6/*E_IPC_DOMAIN_FM*//*,
|
2008-07-26 06:15:57 -07:00
|
|
|
E_FM_OP_UNMOUNT_DONE,
|
2007-06-16 09:18:45 -07:00
|
|
|
0, 0, 0, buf, size);
|
2009-06-06 17:00:41 -07:00
|
|
|
*/
|
2007-06-16 09:18:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
e_volume_unmount(E_Volume *v)
|
|
|
|
{
|
2008-09-24 18:34:39 -07:00
|
|
|
// printf("unmount %s %s\n", v->udi, v->mount_point);
|
2009-06-06 17:00:41 -07:00
|
|
|
if (!v || v->guard) return;
|
|
|
|
|
|
|
|
v->guard = ecore_timer_add(E_FM_UNMOUNT_TIMEOUT, _e_dbus_vol_unmount_timeout, v);
|
|
|
|
v->op = e_hal_device_volume_unmount(_e_dbus_conn, v->udi, NULL,
|
|
|
|
_e_dbus_cb_vol_unmounted, v);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_e_dbus_vol_eject_timeout(void *data)
|
|
|
|
{
|
|
|
|
E_Volume *v = data;
|
|
|
|
DBusError error;
|
|
|
|
char *buf;
|
|
|
|
int size;
|
|
|
|
|
|
|
|
v->guard = NULL;
|
|
|
|
dbus_pending_call_cancel(v->op);
|
|
|
|
error.name = "org.enlightenment.fm2.EjectTimeout";
|
|
|
|
error.message = "Unable to eject the media with specified time-out.";
|
|
|
|
size = _e_dbus_format_error_msg(&buf, v, &error);
|
|
|
|
ecore_ipc_server_send(_e_ipc_server, 6/*E_IPC_DOMAIN_FM*/, E_FM_OP_EJECT_ERROR,
|
|
|
|
0, 0, 0, buf, size);
|
|
|
|
free(buf);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_e_dbus_vb_vol_ejecting_after_unmount(void *data)
|
|
|
|
{
|
|
|
|
E_Volume *v = data;
|
|
|
|
|
|
|
|
v->guard = ecore_timer_add(E_FM_EJECT_TIMEOUT, _e_dbus_vol_eject_timeout, v);
|
|
|
|
v->op = e_hal_device_volume_eject(_e_dbus_conn, v->udi, NULL,
|
|
|
|
_e_dbus_cb_vol_ejected, v);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_dbus_cb_vol_unmounted_before_eject(void *user_data, void *method_return, DBusError *error)
|
|
|
|
{
|
|
|
|
E_Volume *v = user_data;
|
|
|
|
char err;
|
|
|
|
|
|
|
|
err = dbus_error_is_set(error) ? 1 : 0;
|
|
|
|
_e_dbus_cb_vol_unmounted(user_data, method_return, error);
|
|
|
|
|
|
|
|
// delay is required for all message handlers were executed after unmount
|
|
|
|
if (!err)
|
|
|
|
ecore_timer_add(1.0, _e_dbus_vb_vol_ejecting_after_unmount, v);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_dbus_cb_vol_ejected(void *user_data, void *method_return, DBusError *error)
|
|
|
|
{
|
|
|
|
E_Volume *v = user_data;
|
|
|
|
char *buf;
|
|
|
|
int size;
|
|
|
|
|
|
|
|
if (v->guard)
|
|
|
|
{
|
|
|
|
ecore_timer_del(v->guard);
|
|
|
|
v->guard = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dbus_error_is_set(error))
|
|
|
|
{
|
|
|
|
size = _e_dbus_format_error_msg(&buf, v, error);
|
|
|
|
ecore_ipc_server_send(_e_ipc_server, 6/*E_IPC_DOMAIN_FM*/, E_FM_OP_EJECT_ERROR,
|
|
|
|
0, 0, 0, buf, size);
|
|
|
|
dbus_error_free(error);
|
|
|
|
free(buf);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
size = strlen(v->udi) + 1;
|
|
|
|
buf = alloca(size);
|
|
|
|
strcpy(buf, v->udi);
|
|
|
|
ecore_ipc_server_send(_e_ipc_server,
|
|
|
|
6/*E_IPC_DOMAIN_FM*/,
|
|
|
|
E_FM_OP_EJECT_DONE,
|
|
|
|
0, 0, 0, buf, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
e_volume_eject(E_Volume *v)
|
|
|
|
{
|
|
|
|
if (!v || v->guard) return;
|
|
|
|
|
|
|
|
if (v->mounted)
|
|
|
|
{
|
|
|
|
v->guard = ecore_timer_add(E_FM_UNMOUNT_TIMEOUT, _e_dbus_vol_unmount_timeout, v);
|
|
|
|
v->op = e_hal_device_volume_unmount(_e_dbus_conn, v->udi, NULL,
|
|
|
|
_e_dbus_cb_vol_unmounted_before_eject, v);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
v->guard = ecore_timer_add(E_FM_EJECT_TIMEOUT, _e_dbus_vol_eject_timeout, v);
|
|
|
|
v->op = e_hal_device_volume_eject(_e_dbus_conn, v->udi, NULL,
|
|
|
|
_e_dbus_cb_vol_ejected, v);
|
|
|
|
}
|
2007-06-16 09:18:45 -07:00
|
|
|
}
|
|
|
|
|
2007-03-02 09:00:20 -08:00
|
|
|
/* local subsystem functions */
|
|
|
|
static int
|
|
|
|
_e_ipc_init(void)
|
|
|
|
{
|
|
|
|
char *sdir;
|
|
|
|
|
|
|
|
sdir = getenv("E_IPC_SOCKET");
|
|
|
|
if (!sdir)
|
|
|
|
{
|
|
|
|
printf("The E_IPC_SOCKET environment variable is not set. This is\n"
|
|
|
|
"exported by Enlightenment to all processes it launches.\n"
|
|
|
|
"This environment variable must be set and must point to\n"
|
|
|
|
"Enlightenment's IPC socket file (minus port number).\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
_e_ipc_server = ecore_ipc_server_connect(ECORE_IPC_LOCAL_SYSTEM, sdir, 0, NULL);
|
|
|
|
if (!_e_ipc_server)
|
|
|
|
{
|
|
|
|
printf("Cannot connect to enlightenment - abort\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_ADD, _e_ipc_cb_server_add, NULL);
|
|
|
|
ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DEL, _e_ipc_cb_server_del, NULL);
|
|
|
|
ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DATA, _e_ipc_cb_server_data, NULL);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_e_ipc_cb_server_add(void *data, int type, void *event)
|
|
|
|
{
|
|
|
|
Ecore_Ipc_Event_Server_Add *e;
|
|
|
|
|
|
|
|
e = event;
|
|
|
|
ecore_ipc_server_send(e->server,
|
|
|
|
6/*E_IPC_DOMAIN_FM*/,
|
2008-07-26 06:15:57 -07:00
|
|
|
E_FM_OP_HELLO,
|
2007-03-02 09:00:20 -08:00
|
|
|
0, 0, 0, NULL, 0); /* send hello */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_e_ipc_cb_server_del(void *data, int type, void *event)
|
|
|
|
{
|
|
|
|
Ecore_Ipc_Event_Server_Del *e;
|
|
|
|
|
|
|
|
e = event;
|
|
|
|
/* quit now */
|
|
|
|
ecore_main_loop_quit();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-07-26 06:15:57 -07:00
|
|
|
static void
|
|
|
|
_e_fm_monitor_start(int id, const char *path)
|
2007-03-02 09:00:20 -08:00
|
|
|
{
|
2008-07-26 06:15:57 -07:00
|
|
|
E_Fm_Task *task = malloc(sizeof(E_Fm_Task));
|
|
|
|
|
2008-10-27 00:34:22 -07:00
|
|
|
if (!task) return;
|
2008-07-26 06:15:57 -07:00
|
|
|
|
|
|
|
task->id = id;
|
|
|
|
task->type = E_FM_OP_MONITOR_START;
|
|
|
|
task->slave = NULL;
|
2008-10-15 08:12:56 -07:00
|
|
|
task->src = eina_stringshare_add(path);
|
2008-07-26 06:15:57 -07:00
|
|
|
task->dst = NULL;
|
|
|
|
task->rel = NULL;
|
|
|
|
task->rel_to = 0;
|
|
|
|
task->x = 0;
|
|
|
|
task->y = 0;
|
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
_e_fm_tasks = eina_list_append(_e_fm_tasks, task);
|
2008-07-26 06:15:57 -07:00
|
|
|
|
|
|
|
_e_fm_monitor_start_try(task);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_fm_monitor_start_try(E_Fm_Task *task)
|
|
|
|
{
|
|
|
|
E_Dir *ed, *ped = NULL;
|
2007-03-02 09:00:20 -08:00
|
|
|
|
2008-07-26 06:15:57 -07:00
|
|
|
DIR *dir;
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l;
|
2008-07-26 06:15:57 -07:00
|
|
|
|
|
|
|
/* look for any previous dir entries monitoring this dir */
|
2009-08-21 08:08:49 -07:00
|
|
|
EINA_LIST_FOREACH(_e_dirs, l, ed)
|
2007-03-02 09:00:20 -08:00
|
|
|
{
|
2008-07-26 06:15:57 -07:00
|
|
|
if ((ed->mon) && (!strcmp(ed->dir, task->src)))
|
2007-03-02 09:00:20 -08:00
|
|
|
{
|
2008-07-26 06:15:57 -07:00
|
|
|
/* found a previous dir - save it in ped */
|
|
|
|
ped = ed;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* open the dir to list */
|
|
|
|
dir = opendir(task->src);
|
|
|
|
if (!dir)
|
|
|
|
{
|
|
|
|
char buf[PATH_MAX + 4096];
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "Cannot open directory '%s': %s.", task->src, strerror(errno));
|
|
|
|
_e_client_send(task->id, E_FM_OP_ERROR_RETRY_ABORT, buf, strlen(buf) + 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *files = NULL;
|
2008-07-26 06:15:57 -07:00
|
|
|
struct dirent *dp;
|
|
|
|
int dot_order = 0;
|
|
|
|
char buf[4096];
|
|
|
|
FILE *f;
|
|
|
|
|
|
|
|
/* create a new dir entry */
|
|
|
|
ed = calloc(1, sizeof(E_Dir));
|
|
|
|
ed->id = task->id;
|
2008-10-15 08:12:56 -07:00
|
|
|
ed->dir = eina_stringshare_add(task->src);
|
2008-07-26 06:15:57 -07:00
|
|
|
if (!ped)
|
|
|
|
{
|
|
|
|
/* if no previous monitoring dir exists - this one
|
|
|
|
* becomes the master monitor enty */
|
|
|
|
ed->mon = ecore_file_monitor_add(ed->dir, _e_cb_file_monitor, ed);
|
|
|
|
ed->mon_ref = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* an existing monitor exists - ref it up */
|
|
|
|
ed->mon_real = ped;
|
|
|
|
ped->mon_ref++;
|
|
|
|
}
|
2008-10-22 04:49:33 -07:00
|
|
|
_e_dirs = eina_list_append(_e_dirs, ed);
|
2008-07-26 06:15:57 -07:00
|
|
|
|
|
|
|
/* read everything except a .order, . and .. */
|
|
|
|
while ((dp = readdir(dir)))
|
|
|
|
{
|
|
|
|
if ((!strcmp(dp->d_name, ".")) || (!strcmp(dp->d_name, "..")))
|
|
|
|
continue;
|
|
|
|
if (!strcmp(dp->d_name, ".order"))
|
2007-03-02 09:00:20 -08:00
|
|
|
{
|
2008-07-26 06:15:57 -07:00
|
|
|
dot_order = 1;
|
|
|
|
continue;
|
2007-03-02 09:00:20 -08:00
|
|
|
}
|
2008-10-22 04:49:33 -07:00
|
|
|
files = eina_list_append(files, strdup(dp->d_name));
|
2008-07-26 06:15:57 -07:00
|
|
|
}
|
|
|
|
closedir(dir);
|
|
|
|
/* if there was a .order - we need to parse it */
|
|
|
|
if (dot_order)
|
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "%s/.order", task->src);
|
|
|
|
f = fopen(buf, "r");
|
|
|
|
if (f)
|
2007-03-02 09:00:20 -08:00
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *f2 = NULL;
|
2008-07-26 06:15:57 -07:00
|
|
|
int len;
|
|
|
|
char *s;
|
2007-03-02 09:00:20 -08:00
|
|
|
|
2008-07-26 06:15:57 -07:00
|
|
|
/* inset files in order if the existed in file
|
|
|
|
* list before */
|
|
|
|
while (fgets(buf, sizeof(buf), f))
|
2007-03-02 09:00:20 -08:00
|
|
|
{
|
2008-07-26 06:15:57 -07:00
|
|
|
len = strlen(buf);
|
|
|
|
if (len > 0) buf[len - 1] = 0;
|
|
|
|
s = _e_str_list_remove(&files, buf);
|
2008-10-22 04:49:33 -07:00
|
|
|
if (s) f2 = eina_list_append(f2, s);
|
2007-03-02 09:00:20 -08:00
|
|
|
}
|
2008-07-26 06:15:57 -07:00
|
|
|
fclose(f);
|
|
|
|
/* append whats left */
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
files = eina_list_merge(f2, files);
|
2007-03-02 09:00:20 -08:00
|
|
|
}
|
|
|
|
}
|
2008-07-26 06:15:57 -07:00
|
|
|
ed->fq = files;
|
|
|
|
/* FIXME: if .order file- load it, sort all items int it
|
|
|
|
* that are in files then just append whatever is left in
|
|
|
|
* alphabetical order
|
|
|
|
*/
|
|
|
|
/* FIXME: maybe one day we can sort files here and handle
|
|
|
|
* .order file stuff here - but not today
|
|
|
|
*/
|
|
|
|
/* note that we had a .order at all */
|
|
|
|
ed->dot_order = dot_order;
|
|
|
|
if (dot_order)
|
2007-03-02 09:00:20 -08:00
|
|
|
{
|
2008-07-26 06:15:57 -07:00
|
|
|
/* if we did - tell the E about this FIRST - it will
|
|
|
|
* decide what to do if it first sees a .order or not */
|
|
|
|
if (!strcmp(task->src, "/"))
|
|
|
|
snprintf(buf, sizeof(buf), "/.order");
|
|
|
|
else
|
|
|
|
snprintf(buf, sizeof(buf), "%s/.order", task->src);
|
2008-10-22 04:49:33 -07:00
|
|
|
if (eina_list_count(files) == 1)
|
2008-07-26 06:15:57 -07:00
|
|
|
_e_file_add(ed, buf, 2);
|
|
|
|
else
|
|
|
|
_e_file_add(ed, buf, 1);
|
|
|
|
}
|
|
|
|
/* send empty file - indicate empty dir */
|
|
|
|
if (!files) _e_file_add(ed, "", 2);
|
|
|
|
/* and in an idler - list files, statting them etc. */
|
|
|
|
ed->idler = ecore_idler_add(_e_cb_file_mon_list_idler, ed);
|
|
|
|
ed->sync_num = DEF_SYNC_NUM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_fm_monitor_end(int id, const char *path)
|
|
|
|
{
|
|
|
|
E_Fm_Task *task;
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *l;
|
2008-07-26 06:15:57 -07:00
|
|
|
E_Dir *ed;
|
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FOREACH(_e_dirs, l, ed)
|
2008-07-26 06:15:57 -07:00
|
|
|
/* look for the dire entry to stop monitoring */
|
|
|
|
if ((id == ed->id) && (!strcmp(ed->dir, path)))
|
|
|
|
{
|
|
|
|
/* if this is not the real monitoring node - unref the
|
|
|
|
* real one */
|
|
|
|
if (ed->mon_real)
|
2007-03-02 09:00:20 -08:00
|
|
|
{
|
2008-07-26 06:15:57 -07:00
|
|
|
/* unref original monitor node */
|
|
|
|
ed->mon_real->mon_ref--;
|
|
|
|
if (ed->mon_real->mon_ref == 0)
|
2007-03-02 09:00:20 -08:00
|
|
|
{
|
2008-07-26 06:15:57 -07:00
|
|
|
/* original is at 0 ref - free it */
|
|
|
|
_e_dir_del(ed->mon_real);
|
|
|
|
ed->mon_real = NULL;
|
2007-03-02 09:00:20 -08:00
|
|
|
}
|
2008-07-26 06:15:57 -07:00
|
|
|
/* free this node */
|
|
|
|
_e_dir_del(ed);
|
2007-03-02 09:00:20 -08:00
|
|
|
}
|
2008-07-26 06:15:57 -07:00
|
|
|
/* this is a core monitoring node - remove ref */
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ed->mon_ref--;
|
|
|
|
/* we are the last ref - free */
|
|
|
|
if (ed->mon_ref == 0) _e_dir_del(ed);
|
|
|
|
}
|
|
|
|
/* remove from dirs list anyway */
|
2008-10-22 04:49:33 -07:00
|
|
|
_e_dirs = eina_list_remove_list(_e_dirs, l);
|
2008-07-26 06:15:57 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
task = _e_fm_task_get(id);
|
2008-11-16 03:53:02 -08:00
|
|
|
if (task) _e_fm_task_remove(task);
|
2008-07-26 06:15:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static E_Fm_Task *
|
|
|
|
_e_fm_task_get(int id)
|
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l = _e_fm_task_node_get(id);
|
2008-07-26 06:15:57 -07:00
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
return (E_Fm_Task *)eina_list_data_get(l);
|
2008-07-26 06:15:57 -07:00
|
|
|
}
|
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
static Eina_List *
|
2008-07-26 06:15:57 -07:00
|
|
|
_e_fm_task_node_get(int id)
|
|
|
|
{
|
|
|
|
E_Fm_Task *task;
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *l;
|
2008-07-26 06:15:57 -07:00
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FOREACH(_e_fm_tasks, l, task)
|
2008-10-27 00:34:22 -07:00
|
|
|
if (task->id == id)
|
2008-07-26 06:15:57 -07:00
|
|
|
return l;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_fm_task_remove(E_Fm_Task *task)
|
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l = _e_fm_task_node_get(task->id);
|
2008-07-26 06:15:57 -07:00
|
|
|
|
|
|
|
switch(task->type)
|
|
|
|
{
|
|
|
|
case E_FM_OP_MONITOR_START:
|
|
|
|
{
|
|
|
|
E_Dir ted;
|
|
|
|
|
|
|
|
/* we can't open the dir - tell E the dir is deleted as
|
|
|
|
* * we can't look in it */
|
|
|
|
memset(&ted, 0, sizeof(E_Dir));
|
|
|
|
ted.id = task->id;
|
|
|
|
_e_file_mon_dir_del(&ted, task->src);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
_e_fm_tasks = eina_list_remove_list(_e_fm_tasks, l);
|
2008-07-26 06:15:57 -07:00
|
|
|
|
2008-10-27 00:34:22 -07:00
|
|
|
if (task->src) eina_stringshare_del(task->src);
|
|
|
|
if (task->dst) eina_stringshare_del(task->dst);
|
|
|
|
if (task->rel) eina_stringshare_del(task->rel);
|
2008-07-26 06:15:57 -07:00
|
|
|
|
|
|
|
free(task);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_fm_mkdir_try(E_Fm_Task *task)
|
|
|
|
{
|
|
|
|
char buf[PATH_MAX + 4096];
|
|
|
|
|
2008-10-27 00:34:22 -07:00
|
|
|
if (mkdir(task->src, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) < 0)
|
2008-07-26 06:15:57 -07:00
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "Cannot make directory '%s': %s.", task->src, strerror(errno));
|
|
|
|
_e_client_send(task->id, E_FM_OP_ERROR_RETRY_ABORT, buf, strlen(buf) + 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-08-10 19:13:22 -07:00
|
|
|
_e_fm_reorder(ecore_file_file_get(task->src), ecore_file_dir_get(task->src), task->rel, task->rel_to);
|
2008-07-26 06:15:57 -07:00
|
|
|
_e_fm_task_remove(task);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_fm_mkdir(int id, const char *src, const char *rel, int rel_to, int x, int y)
|
|
|
|
{
|
|
|
|
E_Fm_Task *task;
|
|
|
|
|
|
|
|
task = malloc(sizeof(E_Fm_Task));
|
|
|
|
|
|
|
|
task->id = id;
|
|
|
|
task->type = E_FM_OP_MKDIR;
|
|
|
|
task->slave = NULL;
|
2008-10-15 08:12:56 -07:00
|
|
|
task->src = eina_stringshare_add(src);
|
2008-07-26 06:15:57 -07:00
|
|
|
task->dst = NULL;
|
2008-10-15 08:12:56 -07:00
|
|
|
task->rel = eina_stringshare_add(rel);
|
2008-07-26 06:15:57 -07:00
|
|
|
task->x = x;
|
|
|
|
task->y = y;
|
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
_e_fm_tasks = eina_list_append(_e_fm_tasks, task);
|
2008-07-26 06:15:57 -07:00
|
|
|
|
|
|
|
_e_fm_mkdir_try(task);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_fm_handle_error_response(int id, E_Fm_Op_Type type)
|
|
|
|
{
|
|
|
|
E_Fm_Task *task = _e_fm_task_get(id);
|
|
|
|
E_Fm_Slave *slave = NULL;
|
|
|
|
|
2008-10-27 00:34:22 -07:00
|
|
|
if (!task)
|
2008-07-26 06:15:57 -07:00
|
|
|
{
|
|
|
|
slave = _e_fm_slave_get(id);
|
2008-10-27 00:34:22 -07:00
|
|
|
if (slave) _e_fm_slave_send(slave, type, NULL, 0);
|
2008-07-26 06:15:57 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-10-27 00:34:22 -07:00
|
|
|
if (type == E_FM_OP_ERROR_RESPONSE_ABORT)
|
2008-07-26 06:15:57 -07:00
|
|
|
{
|
|
|
|
_e_fm_task_remove(task);
|
|
|
|
}
|
2008-10-27 00:34:22 -07:00
|
|
|
else if (type == E_FM_OP_ERROR_RESPONSE_RETRY)
|
2008-07-26 06:15:57 -07:00
|
|
|
{
|
|
|
|
switch(task->type)
|
|
|
|
{
|
|
|
|
case E_FM_OP_MKDIR:
|
|
|
|
_e_fm_mkdir_try(task);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case E_FM_OP_MONITOR_START:
|
|
|
|
_e_fm_monitor_start_try(task);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-10 19:13:22 -07:00
|
|
|
|
2008-07-26 06:15:57 -07:00
|
|
|
static int
|
|
|
|
_e_ipc_cb_server_data(void *data, int type, void *event)
|
|
|
|
{
|
|
|
|
Ecore_Ipc_Event_Server_Data *e;
|
|
|
|
|
|
|
|
e = event;
|
|
|
|
if (e->major != 6/*E_IPC_DOMAIN_FM*/) return 1;
|
|
|
|
switch (e->minor)
|
|
|
|
{
|
|
|
|
case E_FM_OP_MONITOR_START: /* monitor dir (and implicitly list) */
|
|
|
|
{
|
|
|
|
_e_fm_monitor_start(e->ref, e->data);
|
2007-03-02 09:00:20 -08:00
|
|
|
}
|
|
|
|
break;
|
2008-07-26 06:15:57 -07:00
|
|
|
case E_FM_OP_MONITOR_END: /* monitor dir end */
|
|
|
|
{
|
2008-09-24 18:34:39 -07:00
|
|
|
// printf("End listing directory: %s\n", e->data);
|
2008-07-26 06:15:57 -07:00
|
|
|
_e_fm_monitor_end(e->ref, e->data);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case E_FM_OP_REMOVE: /* fop delete file/dir */
|
2007-03-02 09:00:20 -08:00
|
|
|
{
|
2008-08-10 19:13:22 -07:00
|
|
|
_e_fm_slave_run(E_FM_OP_REMOVE, (const char *)e->data, e->ref);
|
2007-03-02 09:00:20 -08:00
|
|
|
}
|
|
|
|
break;
|
2008-07-26 06:15:57 -07:00
|
|
|
case E_FM_OP_TRASH: /* fop trash file/dir */
|
2007-03-02 09:00:20 -08:00
|
|
|
{
|
2007-04-14 09:28:13 -07:00
|
|
|
E_Fop *fop;
|
|
|
|
|
|
|
|
fop = calloc(1, sizeof(E_Fop));
|
|
|
|
if (fop)
|
|
|
|
{
|
|
|
|
fop->id = e->ref;
|
2008-10-15 08:12:56 -07:00
|
|
|
fop->src = eina_stringshare_add(e->data);
|
2008-10-22 04:49:33 -07:00
|
|
|
_e_fops = eina_list_append(_e_fops, fop);
|
2007-04-14 09:28:13 -07:00
|
|
|
fop->idler = ecore_idler_add(_e_cb_fop_trash_idler, fop);
|
|
|
|
}
|
2007-03-02 09:00:20 -08:00
|
|
|
}
|
|
|
|
break;
|
2008-07-26 06:15:57 -07:00
|
|
|
case E_FM_OP_MOVE: /* fop mv file/dir */
|
2007-04-14 09:28:13 -07:00
|
|
|
{
|
2008-08-10 19:13:22 -07:00
|
|
|
_e_fm_slave_run(E_FM_OP_MOVE, (const char *)e->data, e->ref);
|
2007-04-12 07:34:03 -07:00
|
|
|
}
|
2007-03-02 09:00:20 -08:00
|
|
|
break;
|
2008-07-26 06:15:57 -07:00
|
|
|
case E_FM_OP_COPY: /* fop cp file/dir */
|
2007-04-12 07:34:03 -07:00
|
|
|
{
|
2008-08-10 19:13:22 -07:00
|
|
|
_e_fm_slave_run(E_FM_OP_COPY, (const char *)e->data, e->ref);
|
2007-04-12 07:34:03 -07:00
|
|
|
}
|
2007-03-02 09:00:20 -08:00
|
|
|
break;
|
2009-02-23 21:22:14 -08:00
|
|
|
case E_FM_OP_SYMLINK: /* fop ln -s */
|
|
|
|
{
|
|
|
|
_e_fm_slave_run(E_FM_OP_SYMLINK, (const char *)e->data, e->ref);
|
|
|
|
}
|
|
|
|
break;
|
2008-07-26 06:15:57 -07:00
|
|
|
case E_FM_OP_MKDIR: /* fop mkdir */
|
2007-03-02 09:00:20 -08:00
|
|
|
{
|
2007-04-14 23:24:07 -07:00
|
|
|
const char *src, *rel;
|
|
|
|
int rel_to, x, y;
|
|
|
|
|
|
|
|
src = e->data;
|
|
|
|
rel = src + strlen(src) + 1;
|
|
|
|
memcpy(&rel_to, rel + strlen(rel) + 1, sizeof(int));
|
|
|
|
memcpy(&x, rel + strlen(rel) + 1 + sizeof(int), sizeof(int));
|
|
|
|
memcpy(&y, rel + strlen(rel) + 1 + sizeof(int), sizeof(int));
|
2008-07-26 06:15:57 -07:00
|
|
|
|
|
|
|
_e_fm_mkdir(e->ref, src, rel, rel_to, x, y);
|
2007-03-02 09:00:20 -08:00
|
|
|
}
|
|
|
|
break;
|
2008-07-26 06:15:57 -07:00
|
|
|
case E_FM_OP_MOUNT: /* mount udi mountpoint */
|
2007-06-16 09:18:45 -07:00
|
|
|
{
|
|
|
|
E_Volume *v;
|
|
|
|
const char *udi, *mountpoint;
|
|
|
|
|
|
|
|
udi = e->data;
|
|
|
|
mountpoint = udi + strlen(udi) + 1;
|
|
|
|
v = e_volume_find(udi);
|
|
|
|
if (v)
|
|
|
|
{
|
|
|
|
if (mountpoint[0])
|
|
|
|
{
|
|
|
|
if (v->mount_point) free(v->mount_point);
|
|
|
|
v->mount_point = strdup(mountpoint);
|
|
|
|
}
|
2008-09-24 18:34:39 -07:00
|
|
|
// printf("REQ M\n");
|
2007-06-16 09:18:45 -07:00
|
|
|
e_volume_mount(v);
|
|
|
|
}
|
|
|
|
}
|
2007-03-02 09:00:20 -08:00
|
|
|
break;
|
2008-07-26 06:15:57 -07:00
|
|
|
case E_FM_OP_UNMOUNT:/* unmount udi */
|
2007-06-16 09:18:45 -07:00
|
|
|
{
|
|
|
|
E_Volume *v;
|
|
|
|
const char *udi;
|
|
|
|
|
|
|
|
udi = e->data;
|
|
|
|
v = e_volume_find(udi);
|
|
|
|
if (v)
|
|
|
|
{
|
2008-09-24 18:34:39 -07:00
|
|
|
// printf("REQ UM\n");
|
2007-06-16 09:18:45 -07:00
|
|
|
e_volume_unmount(v);
|
|
|
|
}
|
|
|
|
}
|
2007-03-02 09:00:20 -08:00
|
|
|
break;
|
2009-06-06 17:00:41 -07:00
|
|
|
case E_FM_OP_EJECT:/* eject udi */
|
|
|
|
{
|
|
|
|
E_Volume *v;
|
|
|
|
const char *udi;
|
|
|
|
|
|
|
|
udi = e->data;
|
|
|
|
v = e_volume_find(udi);
|
|
|
|
if (v)
|
|
|
|
e_volume_eject(v);
|
|
|
|
}
|
|
|
|
break;
|
2008-07-26 06:15:57 -07:00
|
|
|
case E_FM_OP_QUIT: /* quit */
|
2007-03-02 09:00:20 -08:00
|
|
|
ecore_main_loop_quit();
|
|
|
|
break;
|
2008-07-26 06:15:57 -07:00
|
|
|
case E_FM_OP_MONITOR_SYNC: /* mon list sync */
|
2007-03-02 09:00:20 -08:00
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l;
|
2009-08-21 08:08:49 -07:00
|
|
|
E_Dir *ed;
|
2007-03-02 09:00:20 -08:00
|
|
|
double stime;
|
|
|
|
|
2009-08-21 08:08:49 -07:00
|
|
|
EINA_LIST_FOREACH(_e_dirs, l, ed)
|
2007-03-02 09:00:20 -08:00
|
|
|
{
|
|
|
|
if (ed->fq)
|
|
|
|
{
|
|
|
|
if (ed->sync == e->response)
|
|
|
|
{
|
|
|
|
stime = ecore_time_get() - ed->sync_time;
|
|
|
|
/* try keep round trips to round trip tolerance */
|
|
|
|
if
|
|
|
|
(stime < (DEF_ROUND_TRIP - DEF_ROUND_TRIP_TOLERANCE))
|
|
|
|
ed->sync_num += 1;
|
|
|
|
else if
|
|
|
|
(stime > (DEF_ROUND_TRIP + DEF_ROUND_TRIP_TOLERANCE))
|
|
|
|
ed->sync_num -= 1;
|
|
|
|
/* always sync at least 1 file */
|
|
|
|
if (ed->sync_num < 1) ed->sync_num = 1;
|
|
|
|
ed->idler = ecore_idler_add(_e_cb_file_mon_list_idler, ed);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
List of changes:
1. Gadcon sities:
-- 'E_Gadcon_Site' enum to list all available sities,
-- added 'is_site' callback for distinguish gadcon sities,
-- 'e_gadcon_site_is_*' helpers written to use in gadget modules,
-- gadcon config dialogs modified to show only gadgets that appropriate
to selected gadcon site,
-- all gadget modules updated for using new callback.
When callback is not provided in module, then gadget can be used in
any gadcon site.
2. Filemanager:
-- added error icon to unexisting path dialog,
-- added callback 'func.abort' to 'E_Fm2_Op_Registry_Entry' to specify
abort operation sequence (if not provided, then operation is not
cancelable),
-- added parameter to 'e_fm2_op_registry_entry_add' to specify abort
method on construct 'E_Fm2_Op_Registry_Entry' or make non-cancelable
operation if this function is not provided,
-- added 'e_fm2_operation_abort' call to cancel efm2 operation,
-- added method '_e_fm2_operation_abort_internal' that represent efm2
default handler of operation cancelling,
-- 'done' and 'total' fields of 'E_Fm2_Op_Registry_Entry' changed to
off_t type, also all message handlers modified to work with it
(to show progress for large files correctly),
-- improved file operation progress processing,
-- added cancel button to operation progress gadget in filemanager window,
-- added delete file glyph to operation progress gadget,
-- improved status message for efm2 operation progress.
3. Filemanager slave:
-- fixed critical bug in message handling via stdin/stdout,
-- fixed critical bug in removing task from list,
-- improved 'E_FM_OP_ABORT' handling,
-- fix rollback counting on moving files.
4. Fileman_opinfo module:
-- a new theme writed: status string and gadget for view operation status
in summary and detail modes,
-- summary mode: operation glyph, state message, progressbar, abort button,
-- detail mode: all for summary + from filename, to filename,
-- summary/detailed button works as trigger,
-- added source of module theme and used images.
4. Pathbar module:
-- non-critical fix, just for safety.
Also patch contains several minor updates to serve main task.
SVN revision: 41224
2009-06-29 07:38:03 -07:00
|
|
|
case E_FM_OP_ABORT: // abort copy/move/delete operation by user
|
|
|
|
{
|
|
|
|
E_Fm_Slave *slave = _e_fm_slave_get(e->ref);
|
|
|
|
if (slave)
|
|
|
|
_e_fm_slave_send(slave, e->minor, NULL, 0);
|
|
|
|
}
|
|
|
|
break;
|
2008-07-26 06:15:57 -07:00
|
|
|
case E_FM_OP_ERROR_RESPONSE_IGNORE_THIS:
|
|
|
|
case E_FM_OP_ERROR_RESPONSE_IGNORE_ALL:
|
|
|
|
case E_FM_OP_ERROR_RESPONSE_ABORT:
|
|
|
|
case E_FM_OP_ERROR_RESPONSE_RETRY:
|
2008-07-20 21:12:39 -07:00
|
|
|
{
|
2008-07-26 06:15:57 -07:00
|
|
|
_e_fm_handle_error_response(e->ref, e->minor);
|
2008-07-20 21:12:39 -07:00
|
|
|
}
|
|
|
|
break;
|
2008-07-26 06:15:57 -07:00
|
|
|
case E_FM_OP_OVERWRITE_RESPONSE_NO:
|
|
|
|
case E_FM_OP_OVERWRITE_RESPONSE_NO_ALL:
|
|
|
|
case E_FM_OP_OVERWRITE_RESPONSE_YES:
|
|
|
|
case E_FM_OP_OVERWRITE_RESPONSE_YES_ALL:
|
2008-07-20 21:12:39 -07:00
|
|
|
{
|
2008-07-26 06:15:57 -07:00
|
|
|
_e_fm_slave_send(_e_fm_slave_get(e->ref), e->minor, NULL, 0);
|
2008-07-20 21:12:39 -07:00
|
|
|
}
|
|
|
|
break;
|
2008-08-10 19:13:22 -07:00
|
|
|
case E_FM_OP_REORDER:
|
|
|
|
{
|
|
|
|
const char *file, *dst, *relative;
|
|
|
|
int after;
|
|
|
|
void *p = e->data;
|
|
|
|
|
|
|
|
file = p;
|
|
|
|
p += strlen(file) + 1;
|
|
|
|
|
|
|
|
dst = p;
|
|
|
|
p += strlen(dst) + 1;
|
|
|
|
|
|
|
|
relative = p;
|
|
|
|
p += strlen(relative) + 1;
|
|
|
|
|
|
|
|
after = *(int *)p;
|
|
|
|
|
|
|
|
_e_fm_reorder(file, dst, relative, after);
|
|
|
|
}
|
|
|
|
break;
|
2007-03-02 09:00:20 -08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* always send back an "OK" for each request so e can basically keep a
|
|
|
|
* count of outstanding requests - maybe for balancing between fm
|
|
|
|
* slaves later. ref_to is set to the the ref id in the request to
|
|
|
|
* allow for async handling later */
|
|
|
|
ecore_ipc_server_send(_e_ipc_server,
|
|
|
|
6/*E_IPC_DOMAIN_FM*/,
|
2008-07-26 06:15:57 -07:00
|
|
|
E_FM_OP_OK,
|
2007-03-02 09:00:20 -08:00
|
|
|
0, e->ref, 0, NULL, 0);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-07-26 06:15:57 -07:00
|
|
|
static int _e_client_send(int id, E_Fm_Op_Type type, void *data, int size)
|
2008-07-20 21:12:39 -07:00
|
|
|
{
|
|
|
|
return ecore_ipc_server_send(_e_ipc_server,
|
|
|
|
6/*E_IPC_DOMAIN_FM*/,
|
2008-07-26 06:15:57 -07:00
|
|
|
type,
|
2008-07-20 21:12:39 -07:00
|
|
|
id, 0, 0, data, size);
|
|
|
|
}
|
|
|
|
|
2008-08-10 19:13:22 -07:00
|
|
|
static int _e_fm_slave_run(E_Fm_Op_Type type, const char *args, int id)
|
2008-07-20 21:12:39 -07:00
|
|
|
{
|
|
|
|
E_Fm_Slave *slave;
|
|
|
|
const char *command;
|
|
|
|
|
|
|
|
slave = malloc(sizeof(E_Fm_Slave));
|
|
|
|
|
2008-07-25 14:32:28 -07:00
|
|
|
if (!slave) return 0;
|
2008-07-20 21:12:39 -07:00
|
|
|
|
2008-10-15 08:12:56 -07:00
|
|
|
command = eina_stringshare_add(_e_prepare_command(type, args));
|
2008-07-20 21:12:39 -07:00
|
|
|
|
|
|
|
slave->id = id;
|
|
|
|
slave->exe = ecore_exe_pipe_run(command, ECORE_EXE_PIPE_WRITE | ECORE_EXE_PIPE_READ | ECORE_EXE_PIPE_ERROR, slave );
|
2008-09-24 18:34:39 -07:00
|
|
|
// printf("EFM command: %s\n", command);
|
2008-07-20 21:12:39 -07:00
|
|
|
|
2008-10-15 08:12:56 -07:00
|
|
|
eina_stringshare_del(command);
|
2008-07-20 21:12:39 -07:00
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
_e_fm_slaves = eina_list_append(_e_fm_slaves, slave);
|
2008-07-20 21:12:39 -07:00
|
|
|
|
|
|
|
return (slave->exe != NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static E_Fm_Slave *_e_fm_slave_get(int id)
|
|
|
|
{
|
2009-08-21 08:08:49 -07:00
|
|
|
Eina_List *l;
|
2008-07-20 21:12:39 -07:00
|
|
|
E_Fm_Slave *slave;
|
|
|
|
|
2009-08-21 08:08:49 -07:00
|
|
|
EINA_LIST_FOREACH(_e_fm_slaves, l, slave)
|
2008-07-20 21:12:39 -07:00
|
|
|
{
|
2008-07-25 14:32:28 -07:00
|
|
|
if (slave->id == id)
|
2008-07-20 21:12:39 -07:00
|
|
|
return slave;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int _e_fm_slave_send(E_Fm_Slave *slave, E_Fm_Op_Type type, void *data, int size)
|
|
|
|
{
|
|
|
|
void *sdata;
|
|
|
|
int ssize;
|
|
|
|
int magic = E_FM_OP_MAGIC;
|
|
|
|
int result;
|
|
|
|
|
|
|
|
ssize = 3 * sizeof(int) + size;
|
|
|
|
sdata = malloc(ssize);
|
|
|
|
|
2008-07-25 14:32:28 -07:00
|
|
|
if (!sdata) return 0;
|
2008-07-20 21:12:39 -07:00
|
|
|
|
|
|
|
memcpy(sdata, &magic, sizeof(int));
|
|
|
|
memcpy(sdata + sizeof(int), &type, sizeof(E_Fm_Op_Type));
|
|
|
|
memcpy(sdata + sizeof(int) + sizeof(E_Fm_Op_Type), &size, sizeof(int));
|
|
|
|
|
|
|
|
memcpy(sdata + 2 * sizeof(int) + sizeof(E_Fm_Op_Type), data, size);
|
|
|
|
|
|
|
|
result = ecore_exe_send(slave->exe, sdata, ssize);
|
|
|
|
|
|
|
|
free(sdata);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int _e_fm_slave_data_cb(void *data, int type, void *event)
|
|
|
|
{
|
|
|
|
Ecore_Exe_Event_Data *e = event;
|
|
|
|
E_Fm_Slave *slave;
|
|
|
|
int magic, id, size;
|
|
|
|
void *sdata;
|
|
|
|
int ssize;
|
|
|
|
|
2008-07-25 14:32:28 -07:00
|
|
|
if (!e) return 1;
|
2008-07-20 21:12:39 -07:00
|
|
|
|
|
|
|
slave = ecore_exe_data_get(e->exe);
|
|
|
|
|
|
|
|
sdata = e->data;
|
|
|
|
ssize = e->size;
|
|
|
|
|
List of changes:
1. Gadcon sities:
-- 'E_Gadcon_Site' enum to list all available sities,
-- added 'is_site' callback for distinguish gadcon sities,
-- 'e_gadcon_site_is_*' helpers written to use in gadget modules,
-- gadcon config dialogs modified to show only gadgets that appropriate
to selected gadcon site,
-- all gadget modules updated for using new callback.
When callback is not provided in module, then gadget can be used in
any gadcon site.
2. Filemanager:
-- added error icon to unexisting path dialog,
-- added callback 'func.abort' to 'E_Fm2_Op_Registry_Entry' to specify
abort operation sequence (if not provided, then operation is not
cancelable),
-- added parameter to 'e_fm2_op_registry_entry_add' to specify abort
method on construct 'E_Fm2_Op_Registry_Entry' or make non-cancelable
operation if this function is not provided,
-- added 'e_fm2_operation_abort' call to cancel efm2 operation,
-- added method '_e_fm2_operation_abort_internal' that represent efm2
default handler of operation cancelling,
-- 'done' and 'total' fields of 'E_Fm2_Op_Registry_Entry' changed to
off_t type, also all message handlers modified to work with it
(to show progress for large files correctly),
-- improved file operation progress processing,
-- added cancel button to operation progress gadget in filemanager window,
-- added delete file glyph to operation progress gadget,
-- improved status message for efm2 operation progress.
3. Filemanager slave:
-- fixed critical bug in message handling via stdin/stdout,
-- fixed critical bug in removing task from list,
-- improved 'E_FM_OP_ABORT' handling,
-- fix rollback counting on moving files.
4. Fileman_opinfo module:
-- a new theme writed: status string and gadget for view operation status
in summary and detail modes,
-- summary mode: operation glyph, state message, progressbar, abort button,
-- detail mode: all for summary + from filename, to filename,
-- summary/detailed button works as trigger,
-- added source of module theme and used images.
4. Pathbar module:
-- non-critical fix, just for safety.
Also patch contains several minor updates to serve main task.
SVN revision: 41224
2009-06-29 07:38:03 -07:00
|
|
|
while (ssize >= 3 * sizeof(int))
|
|
|
|
{
|
2008-07-20 21:12:39 -07:00
|
|
|
memcpy(&magic, sdata, sizeof(int));
|
|
|
|
memcpy(&id, sdata + sizeof(int), sizeof(int));
|
|
|
|
memcpy(&size, sdata + sizeof(int) + sizeof(int), sizeof(int));
|
|
|
|
|
2008-07-25 14:32:28 -07:00
|
|
|
if (magic != E_FM_OP_MAGIC)
|
2008-07-20 21:12:39 -07:00
|
|
|
{
|
2008-07-26 06:15:57 -07:00
|
|
|
printf("%s:%s(%d) Wrong magic number from slave #%d. ", __FILE__, __FUNCTION__, __LINE__, slave->id);
|
List of changes:
1. Gadcon sities:
-- 'E_Gadcon_Site' enum to list all available sities,
-- added 'is_site' callback for distinguish gadcon sities,
-- 'e_gadcon_site_is_*' helpers written to use in gadget modules,
-- gadcon config dialogs modified to show only gadgets that appropriate
to selected gadcon site,
-- all gadget modules updated for using new callback.
When callback is not provided in module, then gadget can be used in
any gadcon site.
2. Filemanager:
-- added error icon to unexisting path dialog,
-- added callback 'func.abort' to 'E_Fm2_Op_Registry_Entry' to specify
abort operation sequence (if not provided, then operation is not
cancelable),
-- added parameter to 'e_fm2_op_registry_entry_add' to specify abort
method on construct 'E_Fm2_Op_Registry_Entry' or make non-cancelable
operation if this function is not provided,
-- added 'e_fm2_operation_abort' call to cancel efm2 operation,
-- added method '_e_fm2_operation_abort_internal' that represent efm2
default handler of operation cancelling,
-- 'done' and 'total' fields of 'E_Fm2_Op_Registry_Entry' changed to
off_t type, also all message handlers modified to work with it
(to show progress for large files correctly),
-- improved file operation progress processing,
-- added cancel button to operation progress gadget in filemanager window,
-- added delete file glyph to operation progress gadget,
-- improved status message for efm2 operation progress.
3. Filemanager slave:
-- fixed critical bug in message handling via stdin/stdout,
-- fixed critical bug in removing task from list,
-- improved 'E_FM_OP_ABORT' handling,
-- fix rollback counting on moving files.
4. Fileman_opinfo module:
-- a new theme writed: status string and gadget for view operation status
in summary and detail modes,
-- summary mode: operation glyph, state message, progressbar, abort button,
-- detail mode: all for summary + from filename, to filename,
-- summary/detailed button works as trigger,
-- added source of module theme and used images.
4. Pathbar module:
-- non-critical fix, just for safety.
Also patch contains several minor updates to serve main task.
SVN revision: 41224
2009-06-29 07:38:03 -07:00
|
|
|
break;
|
2008-07-20 21:12:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
sdata += 3 * sizeof(int);
|
|
|
|
ssize -= 3 * sizeof(int);
|
|
|
|
|
2008-07-25 14:32:28 -07:00
|
|
|
if (id == E_FM_OP_OVERWRITE)
|
2008-07-20 21:12:39 -07:00
|
|
|
{
|
2008-07-26 06:15:57 -07:00
|
|
|
_e_client_send(slave->id, E_FM_OP_OVERWRITE, sdata, size);
|
|
|
|
printf("%s:%s(%d) Overwrite sent to client from slave #%d.\n", __FILE__, __FUNCTION__, __LINE__, slave->id);
|
2008-07-20 21:12:39 -07:00
|
|
|
}
|
2008-07-25 14:32:28 -07:00
|
|
|
else if (id == E_FM_OP_ERROR)
|
2008-07-20 21:12:39 -07:00
|
|
|
{
|
2008-07-26 06:15:57 -07:00
|
|
|
_e_client_send(slave->id, E_FM_OP_ERROR, sdata, size);
|
2008-07-20 21:12:39 -07:00
|
|
|
}
|
2008-07-25 14:32:28 -07:00
|
|
|
else if (id == E_FM_OP_PROGRESS)
|
2008-07-20 21:12:39 -07:00
|
|
|
{
|
2008-07-26 06:15:57 -07:00
|
|
|
_e_client_send(slave->id, E_FM_OP_PROGRESS, sdata, size);
|
2008-07-20 21:12:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
sdata += size;
|
|
|
|
ssize -= size;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int _e_fm_slave_error_cb(void *data, int type, void *event)
|
|
|
|
{
|
|
|
|
Ecore_Exe_Event_Data *e = event;
|
|
|
|
E_Fm_Slave *slave;
|
|
|
|
|
2008-07-25 14:32:28 -07:00
|
|
|
if (e == NULL) return 1;
|
2008-07-20 21:12:39 -07:00
|
|
|
|
|
|
|
slave = ecore_exe_data_get(e->exe);
|
|
|
|
|
2008-10-27 00:33:59 -07:00
|
|
|
printf("EFM: Data from STDERR of slave #%d: %.*s", slave->id, e->size, (char *)e->data);
|
2008-07-20 21:12:39 -07:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int _e_fm_slave_del_cb(void *data, int type, void *event)
|
|
|
|
{
|
|
|
|
Ecore_Exe_Event_Del *e = event;
|
|
|
|
E_Fm_Slave *slave;
|
|
|
|
|
2008-07-25 14:32:28 -07:00
|
|
|
if (!e) return 1;
|
2008-07-20 21:12:39 -07:00
|
|
|
|
|
|
|
slave = ecore_exe_data_get(e->exe);
|
2009-03-17 18:33:06 -07:00
|
|
|
_e_client_send(slave->id, E_FM_OP_QUIT, NULL, 0);
|
2008-07-20 21:12:39 -07:00
|
|
|
|
2008-07-25 14:32:28 -07:00
|
|
|
if (!slave) return 1;
|
2008-07-20 21:12:39 -07:00
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
_e_fm_slaves = eina_list_remove(_e_fm_slaves, (void *)slave);
|
2008-07-20 21:12:39 -07:00
|
|
|
free(slave);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2007-03-02 09:00:20 -08:00
|
|
|
static void
|
|
|
|
_e_cb_file_monitor(void *data, Ecore_File_Monitor *em, Ecore_File_Event event, const char *path)
|
|
|
|
{
|
|
|
|
E_Dir *ed;
|
|
|
|
char *dir, *rp, *drp;
|
|
|
|
const char *file;
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l;
|
2007-03-02 09:00:20 -08:00
|
|
|
|
2007-07-25 10:01:04 -07:00
|
|
|
dir = ecore_file_dir_get(path);
|
|
|
|
file = ecore_file_file_get(path);
|
2007-04-12 07:34:03 -07:00
|
|
|
/* FIXME: get no create events if dir is empty */
|
2007-03-02 09:00:20 -08:00
|
|
|
if ((event == ECORE_FILE_EVENT_CREATED_FILE) ||
|
|
|
|
(event == ECORE_FILE_EVENT_CREATED_DIRECTORY))
|
|
|
|
{
|
|
|
|
rp = ecore_file_realpath(dir);
|
2009-08-21 08:08:49 -07:00
|
|
|
EINA_LIST_FOREACH(_e_dirs, l, ed)
|
2007-03-02 09:00:20 -08:00
|
|
|
{
|
|
|
|
drp = ecore_file_realpath(ed->dir);
|
2007-06-02 09:50:43 -07:00
|
|
|
if (drp)
|
|
|
|
{
|
|
|
|
if (!strcmp(rp, drp))
|
|
|
|
_e_file_add(ed, path, 0);
|
|
|
|
free(drp);
|
|
|
|
}
|
2007-03-02 09:00:20 -08:00
|
|
|
}
|
|
|
|
free(rp);
|
|
|
|
}
|
|
|
|
else if ((event == ECORE_FILE_EVENT_DELETED_FILE) ||
|
|
|
|
(event == ECORE_FILE_EVENT_DELETED_DIRECTORY))
|
|
|
|
{
|
|
|
|
rp = ecore_file_realpath(dir);
|
2009-08-21 08:08:49 -07:00
|
|
|
EINA_LIST_FOREACH(_e_dirs, l, ed)
|
2007-03-02 09:00:20 -08:00
|
|
|
{
|
|
|
|
drp = ecore_file_realpath(ed->dir);
|
2007-06-02 09:50:43 -07:00
|
|
|
if (drp)
|
|
|
|
{
|
|
|
|
if (!strcmp(rp, drp))
|
|
|
|
_e_file_del(ed, path);
|
|
|
|
free(drp);
|
|
|
|
}
|
2007-03-02 09:00:20 -08:00
|
|
|
}
|
|
|
|
free(rp);
|
|
|
|
}
|
|
|
|
else if (event == ECORE_FILE_EVENT_MODIFIED)
|
|
|
|
{
|
|
|
|
rp = ecore_file_realpath(dir);
|
2009-08-21 08:08:49 -07:00
|
|
|
EINA_LIST_FOREACH(_e_dirs, l, ed)
|
2007-03-02 09:00:20 -08:00
|
|
|
{
|
|
|
|
drp = ecore_file_realpath(ed->dir);
|
2007-06-02 09:50:43 -07:00
|
|
|
if (drp)
|
|
|
|
{
|
|
|
|
if (!strcmp(rp, drp))
|
|
|
|
_e_file_mod(ed, path);
|
|
|
|
free(drp);
|
|
|
|
}
|
2007-03-02 09:00:20 -08:00
|
|
|
}
|
|
|
|
free(rp);
|
|
|
|
}
|
|
|
|
else if (event == ECORE_FILE_EVENT_DELETED_SELF)
|
|
|
|
{
|
|
|
|
rp = ecore_file_realpath(path);
|
2009-08-21 08:08:49 -07:00
|
|
|
EINA_LIST_FOREACH(_e_dirs, l, ed)
|
2007-03-02 09:00:20 -08:00
|
|
|
{
|
|
|
|
drp = ecore_file_realpath(ed->dir);
|
2007-06-02 09:50:43 -07:00
|
|
|
if (drp)
|
|
|
|
{
|
|
|
|
if (!strcmp(rp, drp))
|
|
|
|
_e_file_mon_dir_del(ed, path);
|
|
|
|
free(drp);
|
|
|
|
}
|
2007-03-02 09:00:20 -08:00
|
|
|
}
|
|
|
|
free(rp);
|
|
|
|
}
|
|
|
|
free(dir);
|
|
|
|
}
|
|
|
|
|
2007-05-20 01:41:36 -07:00
|
|
|
static int
|
|
|
|
_e_cb_recent_clean(void *data)
|
|
|
|
{
|
|
|
|
E_Dir *ed;
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l, *pl;
|
2007-05-20 01:41:36 -07:00
|
|
|
E_Mod *m;
|
|
|
|
double t_now;
|
|
|
|
|
|
|
|
ed = data;
|
|
|
|
ed->cleaning = 1;
|
|
|
|
t_now = ecore_time_get();
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FOREACH_SAFE(ed->recent_mods, pl, l, m)
|
2007-05-20 01:41:36 -07:00
|
|
|
if ((m->mod) && ((t_now - m->timestamp) >= DEF_MOD_BACKOFF))
|
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
ed->recent_mods = eina_list_remove_list(ed->recent_mods, pl);
|
2007-05-20 01:41:36 -07:00
|
|
|
if (!m->done) _e_file_add_mod(ed, m->path, 5, 0);
|
2008-10-15 08:12:56 -07:00
|
|
|
eina_stringshare_del(m->path);
|
2007-05-20 01:41:36 -07:00
|
|
|
free(m);
|
|
|
|
}
|
|
|
|
ed->cleaning = 0;
|
|
|
|
if (ed->recent_mods) return 1;
|
|
|
|
ed->recent_clean = NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-02 09:00:20 -08:00
|
|
|
static void
|
2008-07-26 06:15:57 -07:00
|
|
|
_e_file_add_mod(E_Dir *ed, const char *path, E_Fm_Op_Type op, int listing)
|
2007-03-02 09:00:20 -08:00
|
|
|
{
|
|
|
|
struct stat st;
|
|
|
|
char *lnk = NULL, *rlnk = NULL;
|
|
|
|
int broken_lnk = 0;
|
|
|
|
int bsz = 0;
|
|
|
|
unsigned char *p, buf
|
|
|
|
/* file add/change format is as follows:
|
|
|
|
*
|
2007-04-14 09:28:13 -07:00
|
|
|
* stat_info[stat size] + broken_link[1] + path[n]\0 + lnk[n]\0 + rlnk[n]\0 */
|
2007-03-02 09:00:20 -08:00
|
|
|
[sizeof(struct stat) + 1 + 4096 + 4096 + 4096];
|
2007-05-20 01:41:36 -07:00
|
|
|
|
|
|
|
/* FIXME: handle BACKOFF */
|
2008-07-26 06:15:57 -07:00
|
|
|
if ((!listing) && (op == E_FM_OP_FILE_CHANGE) && (!ed->cleaning)) /* 5 == mod */
|
2007-05-20 01:41:36 -07:00
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l;
|
2007-05-20 01:41:36 -07:00
|
|
|
E_Mod *m;
|
|
|
|
double t_now;
|
|
|
|
int skip = 0;
|
|
|
|
|
|
|
|
t_now = ecore_time_get();
|
2009-08-21 08:08:49 -07:00
|
|
|
EINA_LIST_FOREACH(ed->recent_mods, l, m)
|
2007-05-20 01:41:36 -07:00
|
|
|
{
|
|
|
|
if ((m->mod) && (!strcmp(m->path, path)))
|
|
|
|
{
|
|
|
|
if ((t_now - m->timestamp) < DEF_MOD_BACKOFF)
|
|
|
|
{
|
|
|
|
m->done = 0;
|
|
|
|
skip = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!skip)
|
|
|
|
{
|
|
|
|
m = calloc(1, sizeof(E_Mod));
|
2008-10-15 08:12:56 -07:00
|
|
|
m->path = eina_stringshare_add(path);
|
2007-05-20 01:41:36 -07:00
|
|
|
m->mod = 1;
|
|
|
|
m->done = 1;
|
|
|
|
m->timestamp = t_now;
|
2008-10-22 04:49:33 -07:00
|
|
|
ed->recent_mods = eina_list_append(ed->recent_mods, m);
|
2007-05-20 01:41:36 -07:00
|
|
|
}
|
|
|
|
if ((!ed->recent_clean) && (ed->recent_mods))
|
|
|
|
ed->recent_clean = ecore_timer_add(DEF_MOD_BACKOFF, _e_cb_recent_clean, ed);
|
|
|
|
if (skip)
|
|
|
|
{
|
|
|
|
// printf("SKIP MOD %s %3.3f\n", path, t_now);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// printf("MOD %s %3.3f\n", path, ecore_time_get());
|
2007-05-03 10:24:13 -07:00
|
|
|
lnk = ecore_file_readlink(path);
|
2008-01-10 23:33:57 -08:00
|
|
|
memset(&st, 0, sizeof(struct stat));
|
2007-03-02 09:00:20 -08:00
|
|
|
if (stat(path, &st) == -1)
|
|
|
|
{
|
2007-04-14 09:28:13 -07:00
|
|
|
if ((path[0] == 0) || (lnk)) broken_lnk = 1;
|
2007-03-02 09:00:20 -08:00
|
|
|
else return;
|
|
|
|
}
|
|
|
|
if ((lnk) && (lnk[0] != '/')) rlnk = ecore_file_realpath(path);
|
2007-05-03 10:24:13 -07:00
|
|
|
else if (lnk) rlnk = strdup(lnk);
|
2007-03-02 09:00:20 -08:00
|
|
|
if (!lnk) lnk = strdup("");
|
|
|
|
if (!rlnk) rlnk = strdup("");
|
|
|
|
|
|
|
|
p = buf;
|
|
|
|
/* NOTE: i am NOT converting this data to portable arch/os independant
|
|
|
|
* format. i am ASSUMING e_fm_main and e are local and built together
|
|
|
|
* and thus this will work. if this ever changes this here needs to
|
|
|
|
* change */
|
|
|
|
memcpy(buf, &st, sizeof(struct stat));
|
|
|
|
p += sizeof(struct stat);
|
|
|
|
|
|
|
|
p[0] = broken_lnk;
|
|
|
|
p += 1;
|
|
|
|
|
2007-05-06 09:23:11 -07:00
|
|
|
strcpy((char *)p, path);
|
2007-03-02 09:00:20 -08:00
|
|
|
p += strlen(path) + 1;
|
|
|
|
|
2007-05-06 09:23:11 -07:00
|
|
|
strcpy((char *)p, lnk);
|
2007-03-02 09:00:20 -08:00
|
|
|
p += strlen(lnk) + 1;
|
|
|
|
|
2007-05-06 09:23:11 -07:00
|
|
|
strcpy((char *)p, rlnk);
|
2007-03-02 09:00:20 -08:00
|
|
|
p += strlen(rlnk) + 1;
|
|
|
|
|
|
|
|
bsz = p - buf;
|
2007-05-20 01:41:36 -07:00
|
|
|
ecore_ipc_server_send(_e_ipc_server, 6/*E_IPC_DOMAIN_FM*/, op, 0, ed->id,
|
2007-03-02 09:00:20 -08:00
|
|
|
listing, buf, bsz);
|
|
|
|
if (lnk) free(lnk);
|
|
|
|
if (rlnk) free(rlnk);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-05-20 01:41:36 -07:00
|
|
|
_e_file_add(E_Dir *ed, const char *path, int listing)
|
2007-03-02 09:00:20 -08:00
|
|
|
{
|
2007-05-20 01:41:36 -07:00
|
|
|
if (!listing)
|
|
|
|
{
|
|
|
|
/* FIXME: handle BACKOFF */
|
|
|
|
}
|
2008-07-26 06:15:57 -07:00
|
|
|
_e_file_add_mod(ed, path, E_FM_OP_FILE_ADD, listing);/*file add*/
|
2007-03-02 09:00:20 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-05-20 01:41:36 -07:00
|
|
|
_e_file_del(E_Dir *ed, const char *path)
|
2007-03-02 09:00:20 -08:00
|
|
|
{
|
2007-05-20 01:41:36 -07:00
|
|
|
{
|
|
|
|
/* FIXME: handle BACKOFF */
|
|
|
|
}
|
2007-03-02 09:00:20 -08:00
|
|
|
ecore_ipc_server_send(_e_ipc_server,
|
|
|
|
6/*E_IPC_DOMAIN_FM*/,
|
2008-07-26 06:15:57 -07:00
|
|
|
E_FM_OP_FILE_DEL,
|
2007-05-20 01:41:36 -07:00
|
|
|
0, ed->id, 0, (void *)path, strlen(path) + 1);
|
2007-03-02 09:00:20 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-05-20 01:41:36 -07:00
|
|
|
_e_file_mod(E_Dir *ed, const char *path)
|
2007-03-02 09:00:20 -08:00
|
|
|
{
|
2007-05-20 01:41:36 -07:00
|
|
|
{
|
|
|
|
/* FIXME: handle BACKOFF */
|
|
|
|
}
|
2008-07-26 06:15:57 -07:00
|
|
|
_e_file_add_mod(ed, path, E_FM_OP_FILE_CHANGE, 0);/*file change*/
|
2007-03-02 09:00:20 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-05-20 01:41:36 -07:00
|
|
|
_e_file_mon_dir_del(E_Dir *ed, const char *path)
|
2007-03-02 09:00:20 -08:00
|
|
|
{
|
|
|
|
ecore_ipc_server_send(_e_ipc_server,
|
|
|
|
6/*E_IPC_DOMAIN_FM*/,
|
2008-07-26 06:15:57 -07:00
|
|
|
E_FM_OP_MONITOR_END,
|
2007-05-20 01:41:36 -07:00
|
|
|
0, ed->id, 0, (void *)path, strlen(path) + 1);
|
2007-03-02 09:00:20 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_file_mon_list_sync(E_Dir *ed)
|
|
|
|
{
|
|
|
|
_e_sync_num++;
|
|
|
|
if (_e_sync_num == 0) _e_sync_num = 1;
|
|
|
|
ed->sync = _e_sync_num;
|
|
|
|
ed->sync_time = ecore_time_get();
|
|
|
|
ecore_ipc_server_send(_e_ipc_server,
|
|
|
|
6/*E_IPC_DOMAIN_FM*/,
|
2008-07-26 06:15:57 -07:00
|
|
|
E_FM_OP_MONITOR_SYNC,
|
2007-03-02 09:00:20 -08:00
|
|
|
0, ed->id, ed->sync, NULL, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_e_cb_file_mon_list_idler(void *data)
|
|
|
|
{
|
|
|
|
E_Dir *ed;
|
|
|
|
int n = 0;
|
|
|
|
char *file, buf[4096];
|
|
|
|
|
|
|
|
ed = data;
|
|
|
|
/* FIXME: spool off files in idlers and handle sync req's */
|
|
|
|
while (ed->fq)
|
|
|
|
{
|
2009-08-21 08:08:49 -07:00
|
|
|
file = eina_list_data_get(ed->fq);
|
2007-03-02 09:00:20 -08:00
|
|
|
if (!((ed->dot_order) && (!strcmp(file, ".order"))))
|
|
|
|
{
|
|
|
|
if (!strcmp(ed->dir, "/"))
|
|
|
|
snprintf(buf, sizeof(buf), "/%s", file);
|
|
|
|
else
|
|
|
|
snprintf(buf, sizeof(buf), "%s/%s", ed->dir, file);
|
2009-08-21 08:08:49 -07:00
|
|
|
_e_file_add(ed, buf, 1);
|
2007-03-02 09:00:20 -08:00
|
|
|
}
|
|
|
|
free(file);
|
2008-10-22 04:49:33 -07:00
|
|
|
ed->fq = eina_list_remove_list(ed->fq, ed->fq);
|
2007-03-02 09:00:20 -08:00
|
|
|
n++;
|
|
|
|
if (n == ed->sync_num)
|
|
|
|
{
|
|
|
|
_e_file_mon_list_sync(ed);
|
|
|
|
ed->idler = NULL;
|
2007-06-02 09:35:10 -07:00
|
|
|
if (!ed->fq) _e_file_add(ed, "", 2);
|
2007-03-02 09:00:20 -08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ed->sync_num = DEF_SYNC_NUM;
|
|
|
|
ed->sync = 0;
|
|
|
|
ed->sync_time = 0.0;
|
|
|
|
ed->idler = NULL;
|
2007-06-02 09:35:10 -07:00
|
|
|
if (!ed->fq) _e_file_add(ed, "", 2);
|
2007-03-02 09:00:20 -08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-04-14 09:28:13 -07:00
|
|
|
static int
|
|
|
|
_e_cb_fop_trash_idler(void *data)
|
|
|
|
{
|
2007-10-10 10:54:04 -07:00
|
|
|
E_Fop *fop = NULL;
|
|
|
|
FILE *info = NULL;
|
|
|
|
const char *trash_dir = NULL;
|
|
|
|
const char *filename = NULL;
|
|
|
|
const char *escname = NULL;
|
|
|
|
const char *dest = NULL;
|
|
|
|
char buf[4096];
|
|
|
|
unsigned int i = 0;
|
|
|
|
struct tm *lt;
|
|
|
|
time_t t;
|
|
|
|
|
|
|
|
/* FIXME: For now, this will only implement 'home trash'
|
|
|
|
* Later, implement mount/remote/removable device trash, if wanted. */
|
|
|
|
|
|
|
|
fop = (E_Fop *)data;
|
|
|
|
if (!fop) return 0;
|
|
|
|
|
2007-10-10 12:04:55 -07:00
|
|
|
/* Check that 'home trash' and subsequesnt dirs exists, create if not */
|
2007-10-10 10:54:04 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/Trash", efreet_data_home_get());
|
2008-10-15 08:12:56 -07:00
|
|
|
trash_dir = eina_stringshare_add(buf);
|
2007-10-10 10:54:04 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/files", trash_dir);
|
2007-10-10 12:37:34 -07:00
|
|
|
if (!ecore_file_mkpath(buf)) return 0;
|
2007-10-10 10:54:04 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/info", trash_dir);
|
2007-10-10 12:37:34 -07:00
|
|
|
if (!ecore_file_mkpath(buf)) return 0;
|
2007-10-10 10:54:04 -07:00
|
|
|
|
2008-10-15 08:12:56 -07:00
|
|
|
filename = eina_stringshare_add(strrchr(fop->src, '/'));
|
2007-10-10 10:54:04 -07:00
|
|
|
escname = ecore_file_escape_name(filename);
|
2008-10-15 08:12:56 -07:00
|
|
|
eina_stringshare_del(filename);
|
2007-10-10 10:54:04 -07:00
|
|
|
|
|
|
|
/* Find path for info file. Pointer address is part of the filename to
|
|
|
|
* alleviate some of the looping in case of multiple filenames with the
|
|
|
|
* same name. Also use the name of the file to help */
|
|
|
|
do
|
|
|
|
{
|
2007-11-05 23:14:24 -08:00
|
|
|
snprintf(buf, sizeof(buf), "%s/file%s.%p.%u", trash_dir, escname,
|
2007-10-10 10:54:04 -07:00
|
|
|
fop, i++);
|
|
|
|
}
|
|
|
|
while (ecore_file_exists(buf));
|
2008-10-15 08:12:56 -07:00
|
|
|
dest = eina_stringshare_add(buf);
|
2007-10-10 10:54:04 -07:00
|
|
|
|
|
|
|
/* Try to move the file */
|
|
|
|
if (rename(fop->src, dest))
|
|
|
|
{
|
|
|
|
if (errno == EXDEV)
|
|
|
|
{
|
|
|
|
/* Move failed. Spec says delete files that can't be trashed */
|
|
|
|
ecore_file_unlink(fop->src);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Move worked. Create info file */
|
2007-11-05 23:14:24 -08:00
|
|
|
snprintf(buf, sizeof(buf), "%s/info%s.%p.%u.trashinfo", trash_dir,
|
2007-10-10 10:54:04 -07:00
|
|
|
escname, fop, --i);
|
|
|
|
info = fopen(buf, "w");
|
|
|
|
if (info)
|
|
|
|
{
|
|
|
|
t = time(NULL);
|
|
|
|
lt = localtime(&t);
|
|
|
|
|
|
|
|
/* Insert info for trashed file */
|
|
|
|
fprintf(info,
|
|
|
|
"[Trash Info]\nPath=%s\nDeletionDate=%04u%02u%02uT%02u:%02u:%02u",
|
|
|
|
fop->src, lt->tm_year+1900, lt->tm_mon+1, lt->tm_mday,
|
|
|
|
lt->tm_hour, lt->tm_min, lt->tm_sec);
|
|
|
|
fclose(info);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
/* Could not create info file. Spec says to put orig file back */
|
|
|
|
rename(dest, fop->src);
|
|
|
|
|
2008-10-15 08:12:56 -07:00
|
|
|
if (dest) eina_stringshare_del(dest);
|
|
|
|
if (trash_dir) eina_stringshare_del(trash_dir);
|
|
|
|
eina_stringshare_del(fop->src);
|
|
|
|
eina_stringshare_del(fop->dst);
|
2007-10-10 10:54:04 -07:00
|
|
|
free(fop);
|
2008-10-22 04:49:33 -07:00
|
|
|
_e_fops = eina_list_remove(_e_fops, fop);
|
2007-10-10 10:54:04 -07:00
|
|
|
return 0;
|
2007-04-14 09:28:13 -07:00
|
|
|
}
|
|
|
|
|
2007-03-02 09:00:20 -08:00
|
|
|
static char *
|
2008-10-22 04:49:33 -07:00
|
|
|
_e_str_list_remove(Eina_List **list, char *str)
|
2007-03-02 09:00:20 -08:00
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l;
|
2007-03-02 09:00:20 -08:00
|
|
|
char *s;
|
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FOREACH(*list, l, s)
|
2007-03-02 09:00:20 -08:00
|
|
|
if (!strcmp(s, str))
|
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
*list = eina_list_remove_list(*list, l);
|
2007-03-02 09:00:20 -08:00
|
|
|
return s;
|
|
|
|
}
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
|
2007-03-02 09:00:20 -08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-04-14 23:24:07 -07:00
|
|
|
static void
|
2008-08-10 19:13:22 -07:00
|
|
|
_e_fm_reorder(const char *file, const char *dst, const char *relative, int after)
|
2007-04-14 23:24:07 -07:00
|
|
|
{
|
2008-08-10 19:13:22 -07:00
|
|
|
char buffer[PATH_MAX];
|
|
|
|
char order[PATH_MAX];
|
|
|
|
|
2008-10-27 00:34:22 -07:00
|
|
|
if (!file || !dst || !relative) return;
|
|
|
|
if (after != 0 && after != 1 && after != 2) return;
|
2008-09-24 18:34:39 -07:00
|
|
|
// printf("%s:%s(%d) Reorder:\n\tfile = %s\n\tdst = %s\n\trelative = %s\n\tafter = %d\n", __FILE__, __FUNCTION__, __LINE__, file, dst, relative, after);
|
2008-08-10 19:13:22 -07:00
|
|
|
|
|
|
|
snprintf(order, sizeof(order), "%s/.order", dst);
|
2008-10-27 00:34:22 -07:00
|
|
|
if (ecore_file_exists(order))
|
2008-08-10 19:13:22 -07:00
|
|
|
{
|
|
|
|
FILE *forder;
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *files = NULL, *l;
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
char *str;
|
2007-04-14 23:24:07 -07:00
|
|
|
|
2008-08-10 19:13:22 -07:00
|
|
|
forder = fopen(order, "r");
|
|
|
|
if (forder)
|
2007-04-14 23:24:07 -07:00
|
|
|
{
|
|
|
|
int len;
|
|
|
|
|
|
|
|
/* inset files in order if the existed in file
|
|
|
|
* list before */
|
2008-08-10 19:13:22 -07:00
|
|
|
while (fgets(buffer, sizeof(buffer), forder))
|
2007-04-14 23:24:07 -07:00
|
|
|
{
|
2008-08-10 19:13:22 -07:00
|
|
|
len = strlen(buffer);
|
|
|
|
if (len > 0) buffer[len - 1] = 0;
|
2008-10-22 04:49:33 -07:00
|
|
|
files = eina_list_append(files, strdup(buffer));
|
2007-04-14 23:24:07 -07:00
|
|
|
}
|
2008-08-10 19:13:22 -07:00
|
|
|
fclose(forder);
|
2007-04-14 23:24:07 -07:00
|
|
|
}
|
|
|
|
/* remove dest file from .order - if there */
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FOREACH(files, l, str)
|
|
|
|
if (!strcmp(str, file))
|
2007-04-14 23:24:07 -07:00
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
free(str);
|
2008-10-22 04:49:33 -07:00
|
|
|
files = eina_list_remove_list(files, l);
|
2007-04-14 23:24:07 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* now insert dest into list or replace entry */
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FOREACH(files, l, str)
|
2007-04-14 23:24:07 -07:00
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
if (!strcmp(str, relative))
|
2007-04-14 23:24:07 -07:00
|
|
|
{
|
2008-08-10 19:13:22 -07:00
|
|
|
if (after == 2) /* replace */
|
2007-04-14 23:24:07 -07:00
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
free(str);
|
2008-08-10 19:13:22 -07:00
|
|
|
l->data = strdup(file);
|
2007-04-14 23:24:07 -07:00
|
|
|
}
|
2008-08-10 19:13:22 -07:00
|
|
|
else if (after == 0) /* before */
|
2007-04-14 23:24:07 -07:00
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
files = eina_list_prepend_relative_list(files, strdup(file), l);
|
2007-04-14 23:24:07 -07:00
|
|
|
}
|
2008-08-10 19:13:22 -07:00
|
|
|
else if (after == 1) /* after */
|
2007-04-14 23:24:07 -07:00
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
files = eina_list_append_relative_list(files, strdup(file), l);
|
2007-04-14 23:24:07 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-08-10 19:13:22 -07:00
|
|
|
|
|
|
|
forder = fopen(order, "w");
|
|
|
|
if (forder)
|
2007-04-14 23:24:07 -07:00
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FREE(files, str)
|
2007-04-14 23:24:07 -07:00
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
fprintf(forder, "%s\n", str);
|
|
|
|
free(str);
|
2007-04-14 23:24:07 -07:00
|
|
|
}
|
2008-08-10 19:13:22 -07:00
|
|
|
fclose(forder);
|
2007-04-14 23:24:07 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-05-20 01:41:36 -07:00
|
|
|
|
|
|
|
static void
|
|
|
|
_e_dir_del(E_Dir *ed)
|
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
void *data;
|
|
|
|
E_Mod *m;
|
|
|
|
|
2008-10-15 08:12:56 -07:00
|
|
|
eina_stringshare_del(ed->dir);
|
2007-05-20 01:41:36 -07:00
|
|
|
if (ed->idler) ecore_idler_del(ed->idler);
|
|
|
|
if (ed->recent_clean)
|
|
|
|
ecore_timer_del(ed->recent_clean);
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FREE(ed->recent_mods, m)
|
2007-05-20 01:41:36 -07:00
|
|
|
{
|
2008-10-15 08:12:56 -07:00
|
|
|
eina_stringshare_del(m->path);
|
2007-05-20 01:41:36 -07:00
|
|
|
free(m);
|
|
|
|
}
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FREE(ed->fq, data)
|
|
|
|
free(data);
|
2007-05-20 01:41:36 -07:00
|
|
|
free(ed);
|
|
|
|
}
|
2008-07-20 21:12:39 -07:00
|
|
|
|
2008-08-13 11:56:09 -07:00
|
|
|
static const char *
|
|
|
|
_e_prepare_command(E_Fm_Op_Type type, const char *args)
|
2008-07-20 21:12:39 -07:00
|
|
|
{
|
2008-08-10 19:13:22 -07:00
|
|
|
char *buffer;
|
|
|
|
unsigned int length = 0;
|
2009-02-23 21:22:14 -08:00
|
|
|
char command[4];
|
2008-07-20 21:12:39 -07:00
|
|
|
|
2008-07-25 14:32:28 -07:00
|
|
|
if (type == E_FM_OP_MOVE)
|
2008-07-20 21:12:39 -07:00
|
|
|
strcpy(command, "mv");
|
2008-07-25 14:32:28 -07:00
|
|
|
else if (type == E_FM_OP_REMOVE)
|
2008-07-20 21:12:39 -07:00
|
|
|
strcpy(command, "rm");
|
2009-02-23 21:22:14 -08:00
|
|
|
else if (type == E_FM_OP_COPY)
|
2008-07-20 21:12:39 -07:00
|
|
|
strcpy(command, "cp");
|
2009-02-23 21:22:14 -08:00
|
|
|
else if (type == E_FM_OP_SYMLINK)
|
|
|
|
strcpy(command, "lns");
|
|
|
|
else
|
|
|
|
strcpy(command, "???");
|
2008-07-20 21:12:39 -07:00
|
|
|
|
2009-01-02 03:19:06 -08:00
|
|
|
length = 256 + strlen(getenv("E_LIB_DIR")) + strlen(args);
|
2008-08-10 19:13:22 -07:00
|
|
|
buffer = malloc(length);
|
2009-01-02 03:19:06 -08:00
|
|
|
length = snprintf(buffer, length,
|
|
|
|
"%s/enlightenment/utils/enlightenment_fm_op %s %s",
|
|
|
|
getenv("E_LIB_DIR"), command, args);
|
2008-07-20 21:12:39 -07:00
|
|
|
|
2008-08-10 19:13:22 -07:00
|
|
|
return buffer;
|
2008-07-20 21:12:39 -07:00
|
|
|
}
|