summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2017-11-07 15:53:44 -0800
committerCedric BAIL <cedric@osg.samsung.com>2017-11-07 16:08:39 -0800
commite32dd07c9d277b99d54cf5d7215e0acfd5075ee3 (patch)
tree0fcd2b0c827997e6596f7e749e5234d355938c69
parentd171cf9639ff859f398ac919cb291f02231e6461 (diff)
elementary: refactor and clean efl_quicklaunch_prepare.
-rw-r--r--src/lib/elementary/elm_main.c69
1 files changed, 15 insertions, 54 deletions
diff --git a/src/lib/elementary/elm_main.c b/src/lib/elementary/elm_main.c
index 551df529c1..ac60653516 100644
--- a/src/lib/elementary/elm_main.c
+++ b/src/lib/elementary/elm_main.c
@@ -1014,7 +1014,6 @@ elm_quicklaunch_prepare(int argc,
1014 qr_handle = dlopen(exe2, RTLD_NOW | RTLD_GLOBAL); 1014 qr_handle = dlopen(exe2, RTLD_NOW | RTLD_GLOBAL);
1015 if (!qr_handle) 1015 if (!qr_handle)
1016 { 1016 {
1017 fprintf(stderr, "dlerr: %s\n", dlerror());
1018 WRN("dlopen('%s') failed: %s", exe2, dlerror()); 1017 WRN("dlopen('%s') failed: %s", exe2, dlerror());
1019 free(exe2); 1018 free(exe2);
1020 return EINA_FALSE; 1019 return EINA_FALSE;
@@ -1046,8 +1045,7 @@ efl_quicklaunch_prepare(int argc,
1046 const char *cwd) 1045 const char *cwd)
1047{ 1046{
1048#ifdef HAVE_FORK 1047#ifdef HAVE_FORK
1049 char *exe, *exe2, *p; 1048 char *exe, *exe2;
1050 char *exename;
1051 1049
1052 if (argc <= 0 || argv == NULL) return EINA_FALSE; 1050 if (argc <= 0 || argv == NULL) return EINA_FALSE;
1053 1051
@@ -1058,74 +1056,37 @@ efl_quicklaunch_prepare(int argc,
1058 return EINA_FALSE; 1056 return EINA_FALSE;
1059 } 1057 }
1060 1058
1061 exe2 = malloc(strlen(exe) + 1 + 7 + strlen(LIBEXT)); 1059 exe2 = eina_file_path_sanitize(exe);
1062 strcpy(exe2, exe);
1063 p = strrchr(exe2, '/');
1064 if (p) p++;
1065 else p = exe2;
1066 exename = alloca(strlen(p) + 1);
1067 strcpy(exename, p);
1068 *p = 0;
1069 strcat(p, "../lib/");
1070 strcat(p, exename);
1071 strcat(p, LIBEXT);
1072 if (access(exe2, R_OK | X_OK) != 0)
1073 ELM_SAFE_FREE(exe2, free);
1074 /* Try linking to executable first. Works with PIE files. */
1075 qr_handle = dlopen(exe, RTLD_NOW | RTLD_GLOBAL);
1076 if (qr_handle)
1077 {
1078 INF("dlopen('%s') = %p", exe, qr_handle);
1079 qre_main = dlsym(qr_handle, "efl_main");
1080 qre_pause = dlsym(qr_handle, "efl_pause");
1081 qre_resume = dlsym(qr_handle, "efl_resume");
1082 qre_terminate = dlsym(qr_handle, "efl_terminate");
1083 if (qre_main)
1084 {
1085 INF("dlsym(%p, 'elm_main') = %p", qr_handle, qre_main);
1086 free(exe2);
1087 free(exe);
1088 return EINA_TRUE;
1089 }
1090 dlclose(qr_handle);
1091 qr_handle = NULL;
1092 }
1093 1060
1094 if (!exe2) 1061 ELM_SAFE_FREE(exe, free);
1095 {
1096 WRN("not quicklauncher capable: '%s'", exe);
1097 free(exe);
1098 return EINA_FALSE;
1099 }
1100 free(exe);
1101 1062
1102 /* Open companion .so file. 1063 /* Try linking to executable first. Works with PIE files. */
1103 * Support for legacy quicklaunch apps with separate library.
1104 */
1105 qr_handle = dlopen(exe2, RTLD_NOW | RTLD_GLOBAL); 1064 qr_handle = dlopen(exe2, RTLD_NOW | RTLD_GLOBAL);
1106 if (!qr_handle) 1065 if (!qr_handle)
1107 { 1066 {
1108 fprintf(stderr, "dlerr: %s\n", dlerror()); 1067 ERR("dlopen('%s') failed: %s", exe2, dlerror());
1109 WRN("dlopen('%s') failed: %s", exe2, dlerror());
1110 free(exe2); 1068 free(exe2);
1111 return EINA_FALSE; 1069 return EINA_FALSE;
1112 } 1070 }
1071
1113 INF("dlopen('%s') = %p", exe2, qr_handle); 1072 INF("dlopen('%s') = %p", exe2, qr_handle);
1114 qre_main = dlsym(qr_handle, "efl_main"); 1073 qre_main = dlsym(qr_handle, "efl_main");
1115 INF("dlsym(%p, 'elm_main') = %p", qr_handle, qre_main); 1074 INF("dlsym(%p, 'efl_main') = %p", qr_handle, qre_main);
1116 qre_pause = dlsym(qr_handle, "efl_pause"); 1075 qre_pause = dlsym(qr_handle, "efl_pause");
1117 qre_resume = dlsym(qr_handle, "efl_resume"); 1076 qre_resume = dlsym(qr_handle, "efl_resume");
1118 qre_terminate = dlsym(qr_handle, "efl_terminate"); 1077 qre_terminate = dlsym(qr_handle, "efl_terminate");
1119 if (!qre_main) 1078 if (qre_main)
1120 { 1079 {
1121 WRN("not quicklauncher capable: no efl_main in '%s'", exe2);
1122 dlclose(qr_handle);
1123 qr_handle = NULL;
1124 free(exe2); 1080 free(exe2);
1125 return EINA_FALSE; 1081 return EINA_TRUE;
1126 } 1082 }
1083
1084 WRN("not quicklauncher capable: no efl_main in '%s'", exe2);
1085 dlclose(qr_handle);
1086 qr_handle = NULL;
1127 free(exe2); 1087 free(exe2);
1128 return EINA_TRUE; 1088
1089 return EINA_FALSE;
1129#else 1090#else
1130 (void)argc; 1091 (void)argc;
1131 (void)argv; 1092 (void)argv;