25 |
25 |
26 #include <mcabber/modules.h> |
26 #include <mcabber/modules.h> |
27 #include <mcabber/commands.h> |
27 #include <mcabber/commands.h> |
28 #include <mcabber/settings.h> |
28 #include <mcabber/settings.h> |
29 #include <mcabber/compl.h> |
29 #include <mcabber/compl.h> |
|
30 #include <mcabber/utils.h> |
30 #include <mcabber/logprint.h> |
31 #include <mcabber/logprint.h> |
31 |
32 |
32 static void extsayng_init(void); |
33 static void extsayng_init(void); |
33 static void extsayng_uninit(void); |
34 static void extsayng_uninit(void); |
34 |
35 |
49 static void screen_run_script(const gchar *args) |
50 static void screen_run_script(const gchar *args) |
50 { |
51 { |
51 GError *err = NULL; |
52 GError *err = NULL; |
52 gchar *argv[] = { "screen", "-r", "-X", "screen", NULL, |
53 gchar *argv[] = { "screen", "-r", "-X", "screen", NULL, |
53 NULL, NULL, NULL, NULL }; |
54 NULL, NULL, NULL, NULL }; |
54 gboolean ret; |
|
55 gchar strwinheight[32]; |
55 gchar strwinheight[32]; |
56 gboolean winsplit = settings_opt_get_int("extsay_split_win"); |
56 gchar *fpath; |
|
57 gboolean winsplit, ret; |
57 |
58 |
58 // screen -r -X screen $path/extsay.sh [jid [winsplit [height]]] |
59 // screen -r -X screen $path/extsay.sh [jid [winsplit [height]]] |
59 argv[4] = (gchar*)settings_opt_get("extsay_script_path"); |
60 fpath = (gchar*)settings_opt_get("extsay_script_path"); |
60 |
61 |
61 // Helper script path |
62 // Helper script path |
62 if (!argv[4] || !argv[4][0]) { |
63 if (!fpath || !fpath[0]) { |
63 scr_log_print(LPRINT_NORMAL, "Please set option 'extsay_script_path'."); |
64 scr_log_print(LPRINT_NORMAL, "Please set option 'extsay_script_path'."); |
64 return; |
65 return; |
65 } |
66 } |
|
67 fpath = expand_filename(fpath); |
|
68 argv[4] = fpath; |
66 |
69 |
67 // Helper script parameter #1 |
70 // Helper script parameter #1 |
68 if (args && *args) |
71 if (args && *args) |
69 argv[5] = (gchar*)args; |
72 argv[5] = (gchar*)args; |
70 else |
73 else |
71 argv[5] = "."; |
74 argv[5] = "."; |
72 |
75 |
73 // Update environment variables for the helper script |
76 // Update parameters for the helper script |
|
77 winsplit = settings_opt_get_int("extsay_split_win"); |
74 if (winsplit) { |
78 if (winsplit) { |
75 gint winheight = settings_opt_get_int("extsay_win_height"); |
79 gint winheight = settings_opt_get_int("extsay_win_height"); |
76 argv[6] = "winsplit"; // Helper script parameter #2 |
80 argv[6] = "winsplit"; // Helper script parameter #2 |
77 if (winheight > 0 && winheight < 256) { |
81 if (winheight > 0 && winheight < 256) { |
78 snprintf(strwinheight, sizeof strwinheight, "%d", winheight); |
82 snprintf(strwinheight, sizeof strwinheight, "%d", winheight); |
85 G_SPAWN_STDOUT_TO_DEV_NULL|G_SPAWN_STDERR_TO_DEV_NULL, |
89 G_SPAWN_STDOUT_TO_DEV_NULL|G_SPAWN_STDERR_TO_DEV_NULL, |
86 NULL, NULL, NULL, &err); |
90 NULL, NULL, NULL, &err); |
87 |
91 |
88 if (!ret) |
92 if (!ret) |
89 scr_LogPrint(LPRINT_NORMAL, err->message); |
93 scr_LogPrint(LPRINT_NORMAL, err->message); |
|
94 |
|
95 g_free(fpath); |
90 } |
96 } |
91 |
97 |
92 static void do_extsayng(gchar *args) |
98 static void do_extsayng(gchar *args) |
93 { |
99 { |
94 gpointer bud; |
100 gpointer bud; |