97 |
97 |
98 static void room_bookmark(gpointer bud, char *arg); |
98 static void room_bookmark(gpointer bud, char *arg); |
99 |
99 |
100 // Global variable for the commands list |
100 // Global variable for the commands list |
101 static GSList *Commands; |
101 static GSList *Commands; |
|
102 static GSList *safe_commands; |
102 |
103 |
103 #ifdef MODULES_ENABLE |
104 #ifdef MODULES_ENABLE |
104 #include "modules.h" |
105 #include "modules.h" |
105 |
106 |
106 gpointer cmd_del(gpointer id) |
107 gpointer cmd_del(gpointer id) |
133 n_cmd->userdata = userdata; |
134 n_cmd->userdata = userdata; |
134 Commands = g_slist_prepend(Commands, n_cmd); |
135 Commands = g_slist_prepend(Commands, n_cmd); |
135 // Add to completion CMD category |
136 // Add to completion CMD category |
136 compl_add_category_word(COMPL_CMD, name); |
137 compl_add_category_word(COMPL_CMD, name); |
137 return n_cmd; |
138 return n_cmd; |
|
139 } |
|
140 |
|
141 // cmd_set_safe(name, safe) |
|
142 // Sets if command can be used in startup configuration file. |
|
143 gboolean cmd_set_safe(const gchar *name, gboolean safe) |
|
144 { |
|
145 GSList *sel; |
|
146 if (!name) |
|
147 return FALSE; |
|
148 for (sel = safe_commands; sel; sel = sel->next) |
|
149 if (!strcmp((const char *)sel->data, name)) { |
|
150 if (safe) |
|
151 return FALSE; |
|
152 else { |
|
153 g_free(sel->data); |
|
154 safe_commands = g_slist_delete_link(safe_commands, sel); |
|
155 } |
|
156 } |
|
157 if (safe) |
|
158 safe_commands = g_slist_append(safe_commands, g_strdup(name)); |
|
159 else |
|
160 return FALSE; |
|
161 return TRUE; |
|
162 } |
|
163 |
|
164 // cmd_is_safe(name) |
|
165 // Returns if command is safe or not |
|
166 gboolean cmd_is_safe(const gchar *name) |
|
167 { |
|
168 GSList *sel; |
|
169 if (!name) |
|
170 return FALSE; |
|
171 for (sel = safe_commands; sel; sel = sel->next) |
|
172 if (!strcmp((const char *)sel->data, name)) |
|
173 return TRUE; |
|
174 return FALSE; |
138 } |
175 } |
139 |
176 |
140 // cmd_init() |
177 // cmd_init() |
141 // Commands table initialization |
178 // Commands table initialization |
142 // !!! |
179 // !!! |
194 cmd_add("status", "Show or set your status", COMPL_STATUS, 0, &do_status, |
231 cmd_add("status", "Show or set your status", COMPL_STATUS, 0, &do_status, |
195 NULL); |
232 NULL); |
196 cmd_add("status_to", "Show or set your status for one recipient", |
233 cmd_add("status_to", "Show or set your status for one recipient", |
197 COMPL_JID, COMPL_STATUS, &do_status_to, NULL); |
234 COMPL_JID, COMPL_STATUS, &do_status_to, NULL); |
198 cmd_add("version", "Show mcabber version", 0, 0, &do_version, NULL); |
235 cmd_add("version", "Show mcabber version", 0, 0, &do_version, NULL); |
|
236 |
|
237 cmd_set_safe("set", TRUE); |
|
238 cmd_set_safe("bind", TRUE); |
|
239 cmd_set_safe("alias", TRUE); |
|
240 cmd_set_safe("pgp", TRUE); |
|
241 cmd_set_safe("source", TRUE); |
|
242 cmd_set_safe("status", TRUE); |
|
243 cmd_set_safe("color", TRUE); |
|
244 cmd_set_safe("otrpolicy", TRUE); |
|
245 cmd_set_safe("module", TRUE); |
199 |
246 |
200 // Status category |
247 // Status category |
201 compl_add_category_word(COMPL_STATUS, "online"); |
248 compl_add_category_word(COMPL_STATUS, "online"); |
202 compl_add_category_word(COMPL_STATUS, "avail"); |
249 compl_add_category_word(COMPL_STATUS, "avail"); |
203 #ifdef WITH_DEPRECATED_STATUS_INVISIBLE |
250 #ifdef WITH_DEPRECATED_STATUS_INVISIBLE |