summaryrefslogtreecommitdiff
path: root/src/bin/e_ipc.c
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2005-05-20 03:09:44 +0000
committerCarsten Haitzler <raster@rasterman.com>2005-05-20 03:09:44 +0000
commit242e7b4744ba3c5254d0d68e567a06fbae031a81 (patch)
treefcd39db716258f0f3d00f542001e5fbe6c8b1e2c /src/bin/e_ipc.c
parentfc0105416156c25ea36bc7bc941b58fe0014bf91 (diff)
shorne's patch
SVN revision: 14861
Diffstat (limited to 'src/bin/e_ipc.c')
-rw-r--r--src/bin/e_ipc.c510
1 files changed, 436 insertions, 74 deletions
diff --git a/src/bin/e_ipc.c b/src/bin/e_ipc.c
index e09b2a2..6022904 100644
--- a/src/bin/e_ipc.c
+++ b/src/bin/e_ipc.c
@@ -7,7 +7,6 @@ static int _e_ipc_cb_client_data(void *data, int type, void *event);
7static void _e_ipc_reply_double_send(Ecore_Ipc_Client *client, double val, int opcode); 7static void _e_ipc_reply_double_send(Ecore_Ipc_Client *client, double val, int opcode);
8static void _e_ipc_reply_int_send(Ecore_Ipc_Client *client, int val, int opcode); 8static void _e_ipc_reply_int_send(Ecore_Ipc_Client *client, int val, int opcode);
9static void _e_ipc_reply_2int_send(Ecore_Ipc_Client *client, int val1, int val2, int opcode); 9static void _e_ipc_reply_2int_send(Ecore_Ipc_Client *client, int val1, int val2, int opcode);
10static char *_e_ipc_path_str_get(char **paths, int *bytes);
11static char *_e_ipc_str_list_get(Evas_List *strs, int *bytes); 10static char *_e_ipc_str_list_get(Evas_List *strs, int *bytes);
12static char *_e_ipc_simple_str_dec(char *data, int bytes); 11static char *_e_ipc_simple_str_dec(char *data, int bytes);
13static char **_e_ipc_multi_str_dec(char *data, int bytes, int str_count); 12static char **_e_ipc_multi_str_dec(char *data, int bytes, int str_count);
@@ -27,6 +26,7 @@ ECORE_IPC_DEC_STRUCT_PROTO(_e_ipc_mouse_binding_dec);
27ECORE_IPC_ENC_EVAS_LIST_PROTO(_e_ipc_key_binding_list_enc); 26ECORE_IPC_ENC_EVAS_LIST_PROTO(_e_ipc_key_binding_list_enc);
28ECORE_IPC_ENC_STRUCT_PROTO(_e_ipc_key_binding_enc); 27ECORE_IPC_ENC_STRUCT_PROTO(_e_ipc_key_binding_enc);
29ECORE_IPC_DEC_STRUCT_PROTO(_e_ipc_key_binding_dec); 28ECORE_IPC_DEC_STRUCT_PROTO(_e_ipc_key_binding_dec);
29ECORE_IPC_ENC_EVAS_LIST_PROTO(_e_ipc_path_list_enc);
30 30
31/* local subsystem globals */ 31/* local subsystem globals */
32static Ecore_Ipc_Server *_e_ipc_server = NULL; 32static Ecore_Ipc_Server *_e_ipc_server = NULL;
@@ -180,26 +180,6 @@ _e_ipc_cb_client_data(void *data __UNUSED__, int type __UNUSED__, void *event)
180 free(data); 180 free(data);
181 } 181 }
182 break; 182 break;
183 case E_IPC_OP_MODULE_DIRS_LIST:
184 {
185 char *dirs[] = {
186 PACKAGE_LIB_DIR"/enlightenment/modules",
187 PACKAGE_LIB_DIR"/enlightenment/modules_extra",
188 "~/.e/e/modules",
189 NULL
190 };
191 char *data;
192 int bytes = 0;
193
194 data = _e_ipc_path_str_get(dirs, &bytes);
195 ecore_ipc_client_send(e->client,
196 E_IPC_DOMAIN_REPLY,
197 E_IPC_OP_MODULE_DIRS_LIST_REPLY,
198 0/*ref*/, 0/*ref_to*/, 0/*response*/,
199 data, bytes);
200 free(data);
201 }
202 break;
203 case E_IPC_OP_BG_SET: 183 case E_IPC_OP_BG_SET:
204 { 184 {
205 char *file; 185 char *file;
@@ -390,26 +370,6 @@ _e_ipc_cb_client_data(void *data __UNUSED__, int type __UNUSED__, void *event)
390 370
391 } 371 }
392 break; 372 break;
393 case E_IPC_OP_BG_DIRS_LIST:
394 {
395 char *dirs[] = {
396 PACKAGE_DATA_DIR"/data/themes",
397 "~/.e/e/backgrounds",
398 "~/.e/e/themes",
399 NULL
400 };
401 char *data;
402 int bytes = 0;
403
404 data = _e_ipc_path_str_get(dirs, &bytes);
405 ecore_ipc_client_send(e->client,
406 E_IPC_DOMAIN_REPLY,
407 E_IPC_OP_BG_DIRS_LIST_REPLY,
408 0/*ref*/, 0/*ref_to*/, 0/*response*/,
409 data, bytes);
410 free(data);
411 }
412 break;
413 case E_IPC_OP_RESTART: 373 case E_IPC_OP_RESTART:
414 { 374 {
415 restart = 1; 375 restart = 1;
@@ -775,6 +735,431 @@ _e_ipc_cb_client_data(void *data __UNUSED__, int type __UNUSED__, void *event)
775 e_config->zone_desks_y_count, 735 e_config->zone_desks_y_count,
776 E_IPC_OP_DESKS_GET_REPLY); 736 E_IPC_OP_DESKS_GET_REPLY);
777 break; 737 break;
738
739 /* Module PATH IPC */
740 case E_IPC_OP_MODULE_DIRS_LIST:
741 {
742 Evas_List *dir_list;
743 char *data;
744 int bytes = 0;
745
746 dir_list = e_path_dir_list_get(path_modules);
747 data = _e_ipc_path_list_enc(dir_list, &bytes);
748 ecore_ipc_client_send(e->client,
749 E_IPC_DOMAIN_REPLY,
750 E_IPC_OP_MODULE_DIRS_LIST_REPLY,
751 0/*ref*/, 0/*ref_to*/, 0/*response*/,
752 data, bytes);
753
754 e_path_dir_list_free(dir_list);
755 free(data);
756 break;
757 }
758 case E_IPC_OP_MODULE_DIRS_APPEND:
759 {
760 char * dir;
761
762 dir = _e_ipc_simple_str_dec(e->data, e->size);
763 e_path_user_path_append(path_modules, dir);
764
765 free(dir);
766 e_config_save_queue();
767 break;
768 }
769 case E_IPC_OP_MODULE_DIRS_PREPEND:
770 {
771 char * dir;
772
773 dir = _e_ipc_simple_str_dec(e->data, e->size);
774 e_path_user_path_prepend(path_modules, dir);
775
776 free(dir);
777 e_config_save_queue();
778 break;
779 }
780 case E_IPC_OP_MODULE_DIRS_REMOVE:
781 {
782 char * dir;
783
784 dir = _e_ipc_simple_str_dec(e->data, e->size);
785 e_path_user_path_remove(path_modules, dir);
786
787 free(dir);
788 e_config_save_queue();
789 break;
790 }
791
792 /* Theme PATH IPC */
793 case E_IPC_OP_THEME_DIRS_LIST:
794 {
795 Evas_List *dir_list;
796 char *data;
797 int bytes = 0;
798
799 dir_list = e_path_dir_list_get(path_themes);
800 data = _e_ipc_path_list_enc(dir_list, &bytes);
801 ecore_ipc_client_send(e->client,
802 E_IPC_DOMAIN_REPLY,
803 E_IPC_OP_THEME_DIRS_LIST_REPLY,
804 0/*ref*/, 0/*ref_to*/, 0/*response*/,
805 data, bytes);
806
807 e_path_dir_list_free(dir_list);
808 free(data);
809 break;
810 }
811 case E_IPC_OP_THEME_DIRS_APPEND:
812 {
813 char * dir;
814
815 dir = _e_ipc_simple_str_dec(e->data, e->size);
816 e_path_user_path_append(path_themes, dir);
817
818 free(dir);
819 e_config_save_queue();
820 break;
821 }
822 case E_IPC_OP_THEME_DIRS_PREPEND:
823 {
824 char * dir;
825
826 dir = _e_ipc_simple_str_dec(e->data, e->size);
827 e_path_user_path_prepend(path_themes, dir);
828
829 free(dir);
830 e_config_save_queue();
831 break;
832 }
833 case E_IPC_OP_THEME_DIRS_REMOVE:
834 {
835 char * dir;
836
837 dir = _e_ipc_simple_str_dec(e->data, e->size);
838 e_path_user_path_remove(path_themes, dir);
839
840 free(dir);
841 e_config_save_queue();
842 break;
843 }
844
845 /* Font Path IPC */
846 case E_IPC_OP_FONT_DIRS_LIST:
847 {
848 Evas_List *dir_list;
849 char *data;
850 int bytes = 0;
851
852 dir_list = e_path_dir_list_get(path_fonts);
853 data = _e_ipc_path_list_enc(dir_list, &bytes);
854 ecore_ipc_client_send(e->client,
855 E_IPC_DOMAIN_REPLY,
856 E_IPC_OP_FONT_DIRS_LIST_REPLY,
857 0/*ref*/, 0/*ref_to*/, 0/*response*/,
858 data, bytes);
859
860 e_path_dir_list_free(dir_list);
861 free(data);
862 break;
863 }
864 case E_IPC_OP_FONT_DIRS_APPEND:
865 {
866 char * dir;
867
868 dir = _e_ipc_simple_str_dec(e->data, e->size);
869 e_path_user_path_append(path_fonts, dir);
870
871 free(dir);
872 e_config_save_queue();
873 break;
874 }
875 case E_IPC_OP_FONT_DIRS_PREPEND:
876 {
877 char * dir;
878
879 dir = _e_ipc_simple_str_dec(e->data, e->size);
880 e_path_user_path_prepend(path_fonts, dir);
881
882 free(dir);
883 e_config_save_queue();
884 break;
885 }
886 case E_IPC_OP_FONT_DIRS_REMOVE:
887 {
888 char * dir;
889
890 dir = _e_ipc_simple_str_dec(e->data, e->size);
891 e_path_user_path_remove(path_fonts, dir);
892
893 free(dir);
894 e_config_save_queue();
895 break;
896 }
897
898 /* data Path IPC */
899 case E_IPC_OP_DATA_DIRS_LIST:
900 {
901 Evas_List *dir_list;
902 char *data;
903 int bytes = 0;
904
905 dir_list = e_path_dir_list_get(path_data);
906 data = _e_ipc_path_list_enc(dir_list, &bytes);
907 ecore_ipc_client_send(e->client,
908 E_IPC_DOMAIN_REPLY,
909 E_IPC_OP_DATA_DIRS_LIST_REPLY,
910 0/*ref*/, 0/*ref_to*/, 0/*response*/,
911 data, bytes);
912
913 e_path_dir_list_free(dir_list);
914 free(data);
915 break;
916 }
917 case E_IPC_OP_DATA_DIRS_APPEND:
918 {
919 char * dir;
920
921 dir = _e_ipc_simple_str_dec(e->data, e->size);
922 e_path_user_path_append(path_data, dir);
923
924 free(dir);
925 e_config_save_queue();
926 break;
927 }
928 case E_IPC_OP_DATA_DIRS_PREPEND:
929 {
930 char * dir;
931
932 dir = _e_ipc_simple_str_dec(e->data, e->size);
933 e_path_user_path_prepend(path_data, dir);
934
935 free(dir);
936 e_config_save_queue();
937 break;
938 }
939 case E_IPC_OP_DATA_DIRS_REMOVE:
940 {
941 char * dir;
942
943 dir = _e_ipc_simple_str_dec(e->data, e->size);
944 e_path_user_path_remove(path_data, dir);
945
946 free(dir);
947 e_config_save_queue();
948 break;
949 }
950
951 /* Images Path IPC */
952 case E_IPC_OP_IMAGE_DIRS_LIST:
953 {
954 Evas_List *dir_list;
955 char *data;
956 int bytes = 0;
957
958 dir_list = e_path_dir_list_get(path_images);
959 data = _e_ipc_path_list_enc(dir_list, &bytes);
960 ecore_ipc_client_send(e->client,
961 E_IPC_DOMAIN_REPLY,
962 E_IPC_OP_IMAGE_DIRS_LIST_REPLY,
963 0/*ref*/, 0/*ref_to*/, 0/*response*/,
964 data, bytes);
965
966 e_path_dir_list_free(dir_list);
967 free(data);
968 break;
969 }
970 case E_IPC_OP_IMAGE_DIRS_APPEND:
971 {
972 char * dir;
973
974 dir = _e_ipc_simple_str_dec(e->data, e->size);
975 e_path_user_path_append(path_images, dir);
976
977 free(dir);
978 e_config_save_queue();
979 break;
980 }
981 case E_IPC_OP_IMAGE_DIRS_PREPEND:
982 {
983 char * dir;
984
985 dir = _e_ipc_simple_str_dec(e->data, e->size);
986 e_path_user_path_prepend(path_images, dir);
987
988 free(dir);
989 e_config_save_queue();
990 break;
991 }
992 case E_IPC_OP_IMAGE_DIRS_REMOVE:
993 {
994 char * dir;
995
996 dir = _e_ipc_simple_str_dec(e->data, e->size);
997 e_path_user_path_remove(path_images, dir);
998
999 free(dir);
1000 e_config_save_queue();
1001 break;
1002 }
1003
1004 /* Init Path IPC */
1005 case E_IPC_OP_INIT_DIRS_LIST:
1006 {
1007 Evas_List *dir_list;
1008 char *data;
1009 int bytes = 0;
1010
1011 dir_list = e_path_dir_list_get(path_init);
1012 data = _e_ipc_path_list_enc(dir_list, &bytes);
1013 ecore_ipc_client_send(e->client,
1014 E_IPC_DOMAIN_REPLY,
1015 E_IPC_OP_INIT_DIRS_LIST_REPLY,
1016 0/*ref*/, 0/*ref_to*/, 0/*response*/,
1017 data, bytes);
1018
1019 e_path_dir_list_free(dir_list);
1020 free(data);
1021 break;
1022 }
1023 case E_IPC_OP_INIT_DIRS_APPEND:
1024 {
1025 char * dir;
1026
1027 dir = _e_ipc_simple_str_dec(e->data, e->size);
1028 e_path_user_path_append(path_init, dir);
1029
1030 free(dir);
1031 e_config_save_queue();
1032 break;
1033 }
1034 case E_IPC_OP_INIT_DIRS_PREPEND:
1035 {
1036 char * dir;
1037
1038 dir = _e_ipc_simple_str_dec(e->data, e->size);
1039 e_path_user_path_prepend(path_init, dir);
1040
1041 free(dir);
1042 e_config_save_queue();
1043 break;
1044 }
1045 case E_IPC_OP_INIT_DIRS_REMOVE:
1046 {
1047 char * dir;
1048
1049 dir = _e_ipc_simple_str_dec(e->data, e->size);
1050 e_path_user_path_remove(path_init, dir);
1051
1052 free(dir);
1053 e_config_save_queue();
1054 break;
1055 }
1056
1057 /* Icon Path IPC */
1058 case E_IPC_OP_ICON_DIRS_LIST:
1059 {
1060 Evas_List *dir_list;
1061 char *data;
1062 int bytes = 0;
1063
1064 dir_list = e_path_dir_list_get(path_icons);
1065 data = _e_ipc_path_list_enc(dir_list, &bytes);
1066 ecore_ipc_client_send(e->client,
1067 E_IPC_DOMAIN_REPLY,
1068 E_IPC_OP_ICON_DIRS_LIST_REPLY,
1069 0/*ref*/, 0/*ref_to*/, 0/*response*/,
1070 data, bytes);
1071
1072 e_path_dir_list_free(dir_list);
1073 free(data);
1074 break;
1075 }
1076 case E_IPC_OP_ICON_DIRS_APPEND:
1077 {
1078 char * dir;
1079
1080 dir = _e_ipc_simple_str_dec(e->data, e->size);
1081 e_path_user_path_append(path_icons, dir);
1082
1083 free(dir);
1084 e_config_save_queue();
1085 break;
1086 }
1087 case E_IPC_OP_ICON_DIRS_PREPEND:
1088 {
1089 char * dir;
1090
1091 dir = _e_ipc_simple_str_dec(e->data, e->size);
1092 e_path_user_path_prepend(path_icons, dir);
1093
1094 free(dir);
1095 e_config_save_queue();
1096 break;
1097 }
1098 case E_IPC_OP_ICON_DIRS_REMOVE:
1099 {
1100 char * dir;
1101
1102 dir = _e_ipc_simple_str_dec(e->data, e->size);
1103 e_path_user_path_remove(path_icons, dir);
1104
1105 free(dir);
1106 e_config_save_queue();
1107 break;
1108 }
1109
1110 /* Icon Path IPC */
1111 case E_IPC_OP_BG_DIRS_LIST:
1112 {
1113 Evas_List *dir_list;
1114 char *data;
1115 int bytes = 0;
1116
1117 dir_list = e_path_dir_list_get(path_backgrounds);
1118 data = _e_ipc_path_list_enc(dir_list, &bytes);
1119 ecore_ipc_client_send(e->client,
1120 E_IPC_DOMAIN_REPLY,
1121 E_IPC_OP_BG_DIRS_LIST_REPLY,
1122 0/*ref*/, 0/*ref_to*/, 0/*response*/,
1123 data, bytes);
1124
1125 e_path_dir_list_free(dir_list);
1126 free(data);
1127 break;
1128 }
1129 case E_IPC_OP_BG_DIRS_APPEND:
1130 {
1131 char * dir;
1132
1133 dir = _e_ipc_simple_str_dec(e->data, e->size);
1134 e_path_user_path_append(path_backgrounds, dir);
1135
1136 free(dir);
1137 e_config_save_queue();
1138 break;
1139 }
1140 case E_IPC_OP_BG_DIRS_PREPEND:
1141 {
1142 char * dir;
1143
1144 dir = _e_ipc_simple_str_dec(e->data, e->size);
1145 e_path_user_path_prepend(path_backgrounds, dir);
1146
1147 free(dir);
1148 e_config_save_queue();
1149 break;
1150 }
1151 case E_IPC_OP_BG_DIRS_REMOVE:
1152 {
1153 char * dir;
1154
1155 dir = _e_ipc_simple_str_dec(e->data, e->size);
1156 e_path_user_path_remove(path_backgrounds, dir);
1157
1158 free(dir);
1159 e_config_save_queue();
1160 break;
1161 }
1162
778 default: 1163 default:
779 break; 1164 break;
780 } 1165 }
@@ -838,39 +1223,6 @@ _e_ipc_reply_2int_send(Ecore_Ipc_Client *client, int val1, int val2, int opcode)
838 } 1223 }
839} 1224}
840 1225
841/*
842 * FIXME: This dosen't handle the case where one of the paths is of the
843 * form: ~moo/bar/baz need to figure out the correct path to the
844 * specified users homedir
845 */
846static char *
847_e_ipc_path_str_get(char **paths, int *bytes)
848{
849 char *data = NULL, **cur, *home;
850 int pos = 0;
851 char tmp[PATH_MAX];
852
853 *bytes = 0;
854 home = e_user_homedir_get();
855 for (cur = paths; *cur != NULL; cur++)
856 {
857 char *p;
858
859 p = *cur;
860 if (*p == '~') snprintf(tmp, PATH_MAX, "%s%s", home, ++p);
861 else snprintf(tmp, PATH_MAX, "%s", p);
862
863 *bytes += strlen(tmp) + 1;
864 data = realloc(data, *bytes);
865
866 memcpy(data + pos, tmp, strlen(tmp));
867 pos = *bytes;
868 data[pos - 1] = 0;
869 }
870 free(home);
871 return data;
872}
873
874/** 1226/**
875 * Encode a list of strings into a flattened data block that looks like 1227 * Encode a list of strings into a flattened data block that looks like
876 * <str>0<str>0... (ie string chars - nul byte in between until the end) 1228 * <str>0<str>0... (ie string chars - nul byte in between until the end)
@@ -1126,3 +1478,13 @@ ECORE_IPC_DEC_STRUCT_PROTO(_e_ipc_key_binding_dec)
1126 ECORE_IPC_DEC_STRUCT_FOOT(); 1478 ECORE_IPC_DEC_STRUCT_FOOT();
1127} 1479}
1128 1480
1481ECORE_IPC_ENC_EVAS_LIST_PROTO(_e_ipc_path_list_enc)
1482{
1483 ECORE_IPC_ENC_EVAS_LIST_HEAD_START(E_Path_Dir);
1484 ECORE_IPC_CNTS(dir);
1485 ECORE_IPC_ENC_EVAS_LIST_HEAD_FINISH();
1486 int l1;
1487 ECORE_IPC_SLEN(l1, dir);
1488 ECORE_IPC_PUTS(dir, l1);
1489 ECORE_IPC_ENC_EVAS_LIST_FOOT();
1490}