aboutsummaryrefslogtreecommitdiffstats
path: root/gtk/main.c
diff options
context:
space:
mode:
authorstig <stig@f5534014-38df-0310-8fa8-9805f1628bb7>2011-02-26 17:23:24 +0000
committerstig <stig@f5534014-38df-0310-8fa8-9805f1628bb7>2011-02-26 17:23:24 +0000
commit9d76427e1b7f58b3bd54218de2f54bd4038630aa (patch)
treeff9d82e6d356cc2b65d77c7dd27a299d0280e130 /gtk/main.c
parentd7f53a80d2a341d4f8446729cb7317d75798afb7 (diff)
Added functionality for handling global profiles.
Global profiles can be installed in a "profiles" directory in the Global configuration directory, and a global profile will be copied to the users profiles on first time usage. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@36077 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'gtk/main.c')
-rw-r--r--gtk/main.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/gtk/main.c b/gtk/main.c
index 7fa965666c..5e776ca8de 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -2218,7 +2218,7 @@ main(int argc, char *argv[])
while ((opt = getopt(argc, argv, optstring)) != -1) {
switch (opt) {
case 'C': /* Configuration Profile */
- if (profile_exists (optarg)) {
+ if (profile_exists (optarg, FALSE)) {
set_profile_name (optarg);
} else {
cmdarg_err("Configuration Profile \"%s\" does not exist", optarg);
@@ -3703,6 +3703,29 @@ prefs_to_capture_opts(void)
gbl_resolv_flags = prefs.name_resolve;
}
+static void copy_global_profile (const gchar *profile_name)
+{
+ char *pf_dir_path, *pf_dir_path2, *pf_filename;
+
+ if (create_persconffile_profile(profile_name, &pf_dir_path) == -1) {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ "Can't create directory\n\"%s\":\n%s.",
+ pf_dir_path, strerror(errno));
+
+ g_free(pf_dir_path);
+ }
+
+ if (copy_persconffile_profile(profile_name, profile_name, TRUE, &pf_filename,
+ &pf_dir_path, &pf_dir_path2) == -1) {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ "Can't copy file \"%s\" in directory\n\"%s\" to\n\"%s\":\n%s.",
+ pf_filename, pf_dir_path2, pf_dir_path, strerror(errno));
+
+ g_free(pf_filename);
+ g_free(pf_dir_path);
+ g_free(pf_dir_path2);
+ }
+}
/* Change configuration profile */
void change_configuration_profile (const gchar *profile_name)
@@ -3712,14 +3735,20 @@ void change_configuration_profile (const gchar *profile_name)
int rf_open_errno;
/* First check if profile exists */
- if (!profile_exists(profile_name)) {
- return;
+ if (!profile_exists(profile_name, FALSE)) {
+ if (profile_exists(profile_name, TRUE)) {
+ /* Copy from global profile */
+ copy_global_profile (profile_name);
+ } else {
+ /* No personal and no global profile exists */
+ return;
+ }
}
/* Get the current geometry, before writing it to disk */
main_save_window_geometry(top_level);
- if (profile_exists(get_profile_name())) {
+ if (profile_exists(get_profile_name(), FALSE)) {
/* Write recent file for profile we are leaving, if it still exists */
write_profile_recent();
}