equal
deleted
inserted
replaced
18 along with this program. If not, see <http://www.gnu.org/licenses/>. |
18 along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 */ |
19 */ |
20 |
20 |
21 #include <unistd.h> |
21 #include <unistd.h> |
22 #include <stdlib.h> |
22 #include <stdlib.h> |
|
23 #include <string.h> |
23 #include <sys/wait.h> |
24 #include <sys/wait.h> |
24 #include <glib/gstdio.h> |
25 #include <glib/gstdio.h> |
25 |
26 |
26 #include <mcabber/modules.h> |
27 #include <mcabber/modules.h> |
27 #include <mcabber/commands.h> |
28 #include <mcabber/commands.h> |
95 g_free(fpath); |
96 g_free(fpath); |
96 } |
97 } |
97 |
98 |
98 static void do_extsayng(gchar *args) |
99 static void do_extsayng(gchar *args) |
99 { |
100 { |
100 gpointer bud; |
101 gboolean expandfjid = FALSE; |
|
102 char *xfjid = NULL; |
|
103 char *res_utf8 = NULL, *fjid_utf8 = NULL; |
101 |
104 |
102 if (!args || !*args || !g_strcmp0(args, ".")) { |
105 if (args && !strncmp(args, "." JID_RESOURCE_SEPARATORSTR, 2)) |
|
106 expandfjid = TRUE; |
|
107 |
|
108 if (!args || !*args || expandfjid || !g_strcmp0(args, ".")) { |
|
109 const gchar *res = args+2; |
|
110 gpointer bud; |
|
111 |
103 if (!current_buddy) { |
112 if (!current_buddy) { |
104 scr_LogPrint(LPRINT_NORMAL, "Please select a buddy."); |
113 scr_LogPrint(LPRINT_NORMAL, "Please select a buddy."); |
105 return; |
114 return; |
106 } |
115 } |
107 |
116 |
111 scr_LogPrint(LPRINT_NORMAL, "This is not a user."); |
120 scr_LogPrint(LPRINT_NORMAL, "This is not a user."); |
112 return; |
121 return; |
113 } |
122 } |
114 |
123 |
115 args = (gchar*)buddy_getjid(bud); |
124 args = (gchar*)buddy_getjid(bud); |
|
125 if (expandfjid && *res) { |
|
126 res_utf8 = to_utf8(res); |
|
127 xfjid = g_strdup_printf("%s%c%s", args, JID_RESOURCE_SEPARATOR, res_utf8); |
|
128 args = xfjid; |
|
129 } |
|
130 } else { |
|
131 args = fjid_utf8 = to_utf8(args); |
116 } |
132 } |
117 |
133 |
118 screen_run_script(args); |
134 if (check_jid_syntax(args)) |
|
135 scr_LogPrint(LPRINT_NORMAL, "Please specify a valid Jabber ID."); |
|
136 else |
|
137 screen_run_script(args); // Launch helper script with resulting JID |
|
138 |
|
139 g_free(res_utf8); |
|
140 g_free(fjid_utf8); |
|
141 g_free(xfjid); |
119 } |
142 } |
120 |
143 |
121 static void extsayng_init(void) |
144 static void extsayng_init(void) |
122 { |
145 { |
123 cmd_add("extsay", "Use external editor to write a message", |
146 cmd_add("extsay", "Use external editor to write a message", |