Qt: Rename profile global to system
It's called system profiles in UI so update function names and variables to use the same name. This will increase code readability. Change-Id: I048e9ea85bd6ebab4a2c3ed1c685487ac8f7e40e Reviewed-on: https://code.wireshark.org/review/34116 Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org> Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall <rknall@gmail.com>
This commit is contained in:
parent
a5d2c5e44c
commit
c37cabe900
|
@ -76,7 +76,7 @@ libwsutil.so.0 libwsutil0 #MINVER#
|
|||
get_datafile_path@Base 1.12.0~rc1
|
||||
get_dirname@Base 1.12.0~rc1
|
||||
get_extcap_dir@Base 1.99.0
|
||||
get_global_profiles_dir@Base 1.12.0~rc1
|
||||
get_system_profiles_dir@Base 3.2.0
|
||||
get_os_version_info@Base 1.99.0
|
||||
get_persconffile_path@Base 1.12.0~rc1
|
||||
get_persdatafile_dir@Base 1.12.0~rc1
|
||||
|
@ -91,7 +91,7 @@ libwsutil.so.0 libwsutil0 #MINVER#
|
|||
get_resource_usage@Base 2.3.0
|
||||
get_systemfile_dir@Base 1.12.0~rc1
|
||||
get_tempfile_path@Base 1.12.0~rc1
|
||||
has_global_profiles@Base 1.12.0~rc1
|
||||
has_system_profiles@Base 3.2.0
|
||||
hkdf_expand@Base 2.5.1
|
||||
ieee80211_chan_to_mhz@Base 1.99.7
|
||||
ieee80211_mhz_to_chan@Base 1.99.7
|
||||
|
|
30
ui/profile.c
30
ui/profile.c
|
@ -41,7 +41,7 @@ GList * edited_profile_list(void) {
|
|||
|
||||
static GList *
|
||||
add_profile_entry(GList *fl, const char *profilename, const char *reference, int status,
|
||||
gboolean is_global, gboolean from_global)
|
||||
gboolean is_system, gboolean from_system)
|
||||
{
|
||||
profile_def *profile;
|
||||
|
||||
|
@ -49,8 +49,8 @@ add_profile_entry(GList *fl, const char *profilename, const char *reference, int
|
|||
profile->name = g_strdup(profilename);
|
||||
profile->reference = g_strdup(reference);
|
||||
profile->status = status;
|
||||
profile->is_global = is_global;
|
||||
profile->from_global = from_global;
|
||||
profile->is_system = is_system;
|
||||
profile->from_system = from_system;
|
||||
return g_list_append(fl, profile);
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ gchar *apply_profile_changes(void)
|
|||
profile1->status = PROF_STAT_EXISTS;
|
||||
|
||||
if (profile1->reference) {
|
||||
if (copy_persconffile_profile(profile1->name, profile1->reference, profile1->from_global,
|
||||
if (copy_persconffile_profile(profile1->name, profile1->reference, profile1->from_system,
|
||||
&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.",
|
||||
|
@ -203,7 +203,7 @@ gchar *apply_profile_changes(void)
|
|||
fl2 = edited_profile_list();
|
||||
while (fl2) {
|
||||
profile2 = (profile_def *) fl2->data;
|
||||
if (!profile2->is_global) {
|
||||
if (!profile2->is_system) {
|
||||
if (strcmp(profile1->name, profile2->name)==0) {
|
||||
/* Profile exists in both lists */
|
||||
found = TRUE;
|
||||
|
@ -235,10 +235,10 @@ gchar *apply_profile_changes(void)
|
|||
|
||||
GList *
|
||||
add_to_profile_list(const char *name, const char *expression, int status,
|
||||
gboolean is_global, gboolean from_global)
|
||||
gboolean is_system, gboolean from_system)
|
||||
{
|
||||
edited_profiles = add_profile_entry(edited_profiles, name, expression, status,
|
||||
is_global, from_global);
|
||||
is_system, from_system);
|
||||
|
||||
return g_list_last(edited_profiles);
|
||||
}
|
||||
|
@ -294,7 +294,7 @@ copy_profile_list(void)
|
|||
|
||||
current_profiles = add_profile_entry(current_profiles, profile->name,
|
||||
profile->reference, profile->status,
|
||||
profile->is_global, profile->from_global);
|
||||
profile->is_system, profile->from_system);
|
||||
flp_src = g_list_next(flp_src);
|
||||
}
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ init_profile_list(void)
|
|||
WS_DIRENT *file; /* current file */
|
||||
const gchar *name;
|
||||
GList *local_profiles = NULL;
|
||||
GList *global_profiles = NULL;
|
||||
GList *system_profiles = NULL;
|
||||
GList *iter;
|
||||
gchar *profiles_dir, *filename;
|
||||
|
||||
|
@ -338,15 +338,15 @@ init_profile_list(void)
|
|||
}
|
||||
g_list_free_full(local_profiles, g_free);
|
||||
|
||||
/* Global profiles */
|
||||
profiles_dir = get_global_profiles_dir();
|
||||
/* System profiles */
|
||||
profiles_dir = get_system_profiles_dir();
|
||||
if ((dir = ws_dir_open(profiles_dir, 0, NULL)) != NULL) {
|
||||
while ((file = ws_dir_read_name(dir)) != NULL) {
|
||||
name = ws_dir_get_name(file);
|
||||
filename = g_strdup_printf ("%s%s%s", profiles_dir, G_DIR_SEPARATOR_S, name);
|
||||
|
||||
if (test_for_directory(filename) == EISDIR) {
|
||||
global_profiles = g_list_prepend(global_profiles, g_strdup(name));
|
||||
system_profiles = g_list_prepend(system_profiles, g_strdup(name));
|
||||
}
|
||||
g_free (filename);
|
||||
}
|
||||
|
@ -354,12 +354,12 @@ init_profile_list(void)
|
|||
}
|
||||
g_free(profiles_dir);
|
||||
|
||||
global_profiles = g_list_sort(global_profiles, (GCompareFunc)g_ascii_strcasecmp);
|
||||
for (iter = g_list_first(global_profiles); iter; iter = g_list_next(iter)) {
|
||||
system_profiles = g_list_sort(system_profiles, (GCompareFunc)g_ascii_strcasecmp);
|
||||
for (iter = g_list_first(system_profiles); iter; iter = g_list_next(iter)) {
|
||||
name = (gchar *)iter->data;
|
||||
add_to_profile_list(name, name, PROF_STAT_EXISTS, TRUE, TRUE);
|
||||
}
|
||||
g_list_free_full(global_profiles, g_free);
|
||||
g_list_free_full(system_profiles, g_free);
|
||||
|
||||
/* Make the current list and the edited list equal */
|
||||
copy_profile_list ();
|
||||
|
|
10
ui/profile.h
10
ui/profile.h
|
@ -31,8 +31,8 @@ typedef struct {
|
|||
char *name; /* profile name */
|
||||
char *reference; /* profile reference */
|
||||
int status;
|
||||
gboolean is_global;
|
||||
gboolean from_global;
|
||||
gboolean is_system;
|
||||
gboolean from_system;
|
||||
} profile_def;
|
||||
|
||||
/** @file
|
||||
|
@ -49,13 +49,13 @@ void init_profile_list(void);
|
|||
* @param name Profile name
|
||||
* @param parent Parent profile name
|
||||
* @param status Current status
|
||||
* @param is_global Profile is in the global configuration directory
|
||||
* @param from_global Profile is copied from the global configuration directory
|
||||
* @param is_system Profile is in the system configuration directory
|
||||
* @param from_system Profile is copied from the system configuration directory
|
||||
*
|
||||
* @return A pointer to the new profile list
|
||||
*/
|
||||
GList *add_to_profile_list(const char *name, const char *parent, int status,
|
||||
gboolean is_global, gboolean from_global);
|
||||
gboolean is_system, gboolean from_system);
|
||||
|
||||
/** Refresh the current (non-edited) profile list.
|
||||
*/
|
||||
|
|
|
@ -553,7 +553,7 @@ void MainStatusBar::showProfileMenu(const QPoint &global_pos, Qt::MouseButton bu
|
|||
{
|
||||
pa = profile_menu_.addAction(name);
|
||||
}
|
||||
else if ( idx.data(ProfileModel::DATA_IS_GLOBAL).toBool() )
|
||||
else if ( idx.data(ProfileModel::DATA_IS_SYSTEM).toBool() )
|
||||
{
|
||||
/* Check if this profile does not exist as user */
|
||||
if ( cnt == model.findByName(name) )
|
||||
|
@ -571,7 +571,7 @@ void MainStatusBar::showProfileMenu(const QPoint &global_pos, Qt::MouseButton bu
|
|||
|
||||
pa->setFont(idx.data(Qt::FontRole).value<QFont>());
|
||||
pa->setProperty("profile_name", idx.data());
|
||||
pa->setProperty("profile_is_global", idx.data(ProfileModel::DATA_IS_GLOBAL));
|
||||
pa->setProperty("profile_is_system", idx.data(ProfileModel::DATA_IS_SYSTEM));
|
||||
|
||||
connect(pa, &QAction::triggered, this, &MainStatusBar::switchToProfile);
|
||||
}
|
||||
|
@ -587,7 +587,7 @@ void MainStatusBar::showProfileMenu(const QPoint &global_pos, Qt::MouseButton bu
|
|||
bool enable_edit = false;
|
||||
|
||||
QModelIndex idx = model.activeProfile();
|
||||
if ( ! idx.data(ProfileModel::DATA_IS_DEFAULT).toBool() && ! idx.data(ProfileModel::DATA_IS_GLOBAL).toBool() )
|
||||
if ( ! idx.data(ProfileModel::DATA_IS_DEFAULT).toBool() && ! idx.data(ProfileModel::DATA_IS_SYSTEM).toBool() )
|
||||
enable_edit = true;
|
||||
|
||||
profile_menu_.setTitle(tr("Switch to"));
|
||||
|
|
|
@ -44,19 +44,19 @@ bool ProfileSortModel::lessThan(const QModelIndex &source_left, const QModelInde
|
|||
if ( source_right.column() != ProfileModel::COL_NAME )
|
||||
right = source_right.sibling(source_right.row(), ProfileModel::COL_NAME);
|
||||
|
||||
bool igL = left.data(ProfileModel::DATA_IS_GLOBAL).toBool();
|
||||
bool igR = right.data(ProfileModel::DATA_IS_GLOBAL).toBool();
|
||||
bool isL = left.data(ProfileModel::DATA_IS_SYSTEM).toBool();
|
||||
bool isR = right.data(ProfileModel::DATA_IS_SYSTEM).toBool();
|
||||
|
||||
if (left.data(ProfileModel::DATA_STATUS).toInt() == PROF_STAT_DEFAULT)
|
||||
igL = true;
|
||||
isL = true;
|
||||
if (right.data(ProfileModel::DATA_STATUS).toInt() == PROF_STAT_DEFAULT)
|
||||
igR = true;
|
||||
isR = true;
|
||||
|
||||
if ( igL && ! igR )
|
||||
if ( isL && ! isR )
|
||||
return true;
|
||||
else if ( ! igL && igR )
|
||||
else if ( ! isL && isR )
|
||||
return false;
|
||||
else if ( igL && igR )
|
||||
else if ( isL && isR )
|
||||
{
|
||||
if (left.data(ProfileModel::DATA_STATUS) == PROF_STAT_DEFAULT)
|
||||
return true;
|
||||
|
@ -87,10 +87,10 @@ bool ProfileSortModel::filterAcceptsRow(int source_row, const QModelIndex &) con
|
|||
|
||||
if ( ft_ != ProfileSortModel::AllProfiles )
|
||||
{
|
||||
bool gl = idx.data(ProfileModel::DATA_IS_GLOBAL).toBool();
|
||||
bool gl = idx.data(ProfileModel::DATA_IS_SYSTEM).toBool();
|
||||
if ( ft_ == ProfileSortModel::UserProfiles && gl )
|
||||
accept = false;
|
||||
else if ( ft_ == ProfileSortModel::GlobalProfiles && ! gl )
|
||||
else if ( ft_ == ProfileSortModel::SystemProfiles && ! gl )
|
||||
accept = false;
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ GList * ProfileModel::entry(profile_def *ref) const
|
|||
GList *fl_entry = edited_profile_list();
|
||||
while (fl_entry && fl_entry->data) {
|
||||
profile_def *profile = reinterpret_cast<profile_def *>(fl_entry->data);
|
||||
if (strcmp(ref->name, profile->name) == 0 && ref->is_global == profile->is_global)
|
||||
if (strcmp(ref->name, profile->name) == 0 && ref->is_system == profile->is_system)
|
||||
{
|
||||
if ( ( ref->reference == Q_NULLPTR && profile->reference == Q_NULLPTR )
|
||||
|| ( ( ref->reference != Q_NULLPTR && profile->reference != Q_NULLPTR )
|
||||
|
@ -223,7 +223,7 @@ QVariant ProfileModel::dataDisplay(const QModelIndex &index) const
|
|||
case COL_TYPE:
|
||||
if ( prof->status == PROF_STAT_DEFAULT )
|
||||
return tr("Default");
|
||||
else if ( prof->is_global )
|
||||
else if ( prof->is_system )
|
||||
return tr("System");
|
||||
else
|
||||
return tr("User");
|
||||
|
@ -245,10 +245,10 @@ QVariant ProfileModel::dataFontRole(const QModelIndex &index) const
|
|||
|
||||
QFont font;
|
||||
|
||||
if ( prof->is_global )
|
||||
if ( prof->is_system )
|
||||
font.setItalic(true);
|
||||
|
||||
if ( set_profile_.compare(prof->name) == 0 && ! prof->is_global )
|
||||
if ( set_profile_.compare(prof->name) == 0 && ! prof->is_system )
|
||||
font.setBold(true);
|
||||
|
||||
if ( prof->status == PROF_STAT_DEFAULT && reset_default_ )
|
||||
|
@ -272,7 +272,7 @@ QVariant ProfileModel::dataBackgroundRole(const QModelIndex &index) const
|
|||
if ( prof->status == PROF_STAT_DEFAULT && reset_default_ )
|
||||
return ColorUtils::fromColorT(&prefs.gui_text_deprecated);
|
||||
|
||||
QList<int> rows = const_cast<ProfileModel *>(this)->findAllByNameAndVisibility(QString(prof->name), prof->is_global);
|
||||
QList<int> rows = const_cast<ProfileModel *>(this)->findAllByNameAndVisibility(QString(prof->name), prof->is_system);
|
||||
if ( rows.count() > 1 )
|
||||
return ColorUtils::fromColorT(&prefs.gui_text_invalid);
|
||||
|
||||
|
@ -290,7 +290,7 @@ QVariant ProfileModel::dataToolTipRole(const QModelIndex &idx) const
|
|||
|
||||
QString msg;
|
||||
|
||||
if (prof->is_global)
|
||||
if (prof->is_system)
|
||||
return tr("This is a system provided profile.");
|
||||
else
|
||||
return dataPath(idx);
|
||||
|
@ -314,7 +314,7 @@ QVariant ProfileModel::dataPath(const QModelIndex &index) const
|
|||
return tr("Resetting to default");
|
||||
case PROF_STAT_EXISTS:
|
||||
{
|
||||
QString profile_path = prof->is_global ? get_global_profiles_dir() : get_profiles_dir();
|
||||
QString profile_path = prof->is_system ? get_system_profiles_dir() : get_profiles_dir();
|
||||
profile_path.append(QDir::separator()).append(prof->name);
|
||||
return profile_path;
|
||||
}
|
||||
|
@ -339,7 +339,7 @@ QVariant ProfileModel::dataPath(const QModelIndex &index) const
|
|||
{
|
||||
QString msg = QString("%1 %2").arg(tr("Copied from: ")).arg(prof->reference);
|
||||
|
||||
if ( profile_exists(prof->reference, TRUE) && prof->from_global )
|
||||
if ( profile_exists(prof->reference, TRUE) && prof->from_system )
|
||||
msg.append(QString(" (%1)").arg(tr("system provided")));
|
||||
else
|
||||
{
|
||||
|
@ -386,15 +386,15 @@ QVariant ProfileModel::data(const QModelIndex &index, int role) const
|
|||
return qVariantFromValue(prof->status);
|
||||
case ProfileModel::DATA_IS_DEFAULT:
|
||||
return qVariantFromValue(prof->status == PROF_STAT_DEFAULT);
|
||||
case ProfileModel::DATA_IS_GLOBAL:
|
||||
return qVariantFromValue(prof->is_global);
|
||||
case ProfileModel::DATA_IS_SYSTEM:
|
||||
return qVariantFromValue(prof->is_system);
|
||||
case ProfileModel::DATA_IS_SELECTED:
|
||||
{
|
||||
QModelIndex selected = activeProfile();
|
||||
if ( selected.isValid() && selected.row() < profiles_.count() )
|
||||
{
|
||||
profile_def * selprof = guard(selected.row());
|
||||
if ( selprof && selprof->is_global != prof->is_global )
|
||||
if ( selprof && selprof->is_system != prof->is_system )
|
||||
return qVariantFromValue(false);
|
||||
|
||||
if ( selprof && strcmp(selprof->name, prof->name) == 0 )
|
||||
|
@ -451,7 +451,7 @@ Qt::ItemFlags ProfileModel::flags(const QModelIndex &index) const
|
|||
if ( ! prof )
|
||||
return fl;
|
||||
|
||||
if ( index.column() == ProfileModel::COL_NAME && prof->status != PROF_STAT_DEFAULT && ! prof->is_global )
|
||||
if ( index.column() == ProfileModel::COL_NAME && prof->status != PROF_STAT_DEFAULT && ! prof->is_system )
|
||||
fl |= Qt::ItemIsEditable;
|
||||
|
||||
return fl;
|
||||
|
@ -466,20 +466,20 @@ int ProfileModel::findByName(QString name)
|
|||
return row;
|
||||
}
|
||||
|
||||
int ProfileModel::findByNameAndVisibility(QString name, bool isGlobal)
|
||||
int ProfileModel::findByNameAndVisibility(QString name, bool isSystem)
|
||||
{
|
||||
QList<int> result = findAllByNameAndVisibility(name, isGlobal);
|
||||
QList<int> result = findAllByNameAndVisibility(name, isSystem);
|
||||
return result.count() == 0 ? -1 : result.at(0);
|
||||
}
|
||||
|
||||
QList<int> ProfileModel::findAllByNameAndVisibility(QString name, bool isGlobal)
|
||||
QList<int> ProfileModel::findAllByNameAndVisibility(QString name, bool isSystem)
|
||||
{
|
||||
QList<int> result;
|
||||
|
||||
for ( int cnt = 0; cnt < profiles_.count(); cnt++ )
|
||||
{
|
||||
profile_def * prof = guard(cnt);
|
||||
if ( prof && static_cast<bool>(prof->is_global) == isGlobal && name.compare(prof->name) == 0 )
|
||||
if ( prof && static_cast<bool>(prof->is_system) == isSystem && name.compare(prof->name) == 0 )
|
||||
result << cnt;
|
||||
}
|
||||
|
||||
|
@ -513,11 +513,11 @@ QModelIndex ProfileModel::duplicateEntry(QModelIndex idx)
|
|||
return QModelIndex();
|
||||
|
||||
QString parent = prof->name;
|
||||
if ( ! prof->is_global && prof->status != PROF_STAT_CHANGED && prof->status != PROF_STAT_NEW )
|
||||
if ( ! prof->is_system && prof->status != PROF_STAT_CHANGED && prof->status != PROF_STAT_NEW )
|
||||
parent = get_profile_parent (prof->name);
|
||||
|
||||
QString new_name;
|
||||
if (prof->is_global && ! profile_exists (parent.toUtf8().constData(), FALSE))
|
||||
if (prof->is_system && ! profile_exists (parent.toUtf8().constData(), FALSE))
|
||||
new_name = QString(prof->name);
|
||||
else
|
||||
new_name = QString("%1 (%2)").arg(parent).arg(tr("copy", "noun"));
|
||||
|
@ -535,10 +535,10 @@ QModelIndex ProfileModel::duplicateEntry(QModelIndex idx)
|
|||
new_name = copyName;
|
||||
}
|
||||
|
||||
if ( new_name.compare(QString(new_name.toUtf8().constData())) != 0 && !prof->is_global )
|
||||
if ( new_name.compare(QString(new_name.toUtf8().constData())) != 0 && !prof->is_system )
|
||||
return QModelIndex();
|
||||
|
||||
add_to_profile_list(new_name.toUtf8().constData(), parent.toUtf8().constData(), PROF_STAT_COPY, FALSE, prof->from_global);
|
||||
add_to_profile_list(new_name.toUtf8().constData(), parent.toUtf8().constData(), PROF_STAT_COPY, FALSE, prof->from_system);
|
||||
loadProfiles();
|
||||
|
||||
int row = findByNameAndVisibility(new_name, false);
|
||||
|
@ -557,7 +557,7 @@ void ProfileModel::deleteEntry(QModelIndex idx)
|
|||
if ( ! prof )
|
||||
return;
|
||||
|
||||
if ( prof->is_global )
|
||||
if ( prof->is_system )
|
||||
return;
|
||||
|
||||
if ( prof->status == PROF_STAT_DEFAULT )
|
||||
|
@ -597,7 +597,7 @@ QModelIndex ProfileModel::activeProfile() const
|
|||
if ( row >= 0 )
|
||||
{
|
||||
profile_def * prof = profiles_.at(row);
|
||||
if ( prof->is_global )
|
||||
if ( prof->is_system )
|
||||
return QModelIndex();
|
||||
|
||||
return index(row, ProfileModel::COL_NAME);
|
||||
|
@ -707,7 +707,7 @@ QStringList ProfileModel::exportFileList(QModelIndexList items)
|
|||
foreach(QModelIndex idx, items)
|
||||
{
|
||||
profile_def * prof = guard(idx.row());
|
||||
if ( prof->is_global || QString(prof->name).compare(DEFAULT_PROFILE) == 0 )
|
||||
if ( prof->is_system || QString(prof->name).compare(DEFAULT_PROFILE) == 0 )
|
||||
continue;
|
||||
|
||||
if ( ! idx.data(ProfileModel::DATA_PATH_IS_NOT_DESCRIPTION).toBool() )
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
|
||||
enum FilterType {
|
||||
AllProfiles = 0,
|
||||
GlobalProfiles,
|
||||
SystemProfiles,
|
||||
UserProfiles
|
||||
};
|
||||
|
||||
|
@ -63,7 +63,7 @@ public:
|
|||
enum {
|
||||
DATA_STATUS = Qt::UserRole,
|
||||
DATA_IS_DEFAULT,
|
||||
DATA_IS_GLOBAL,
|
||||
DATA_IS_SYSTEM,
|
||||
DATA_IS_SELECTED,
|
||||
DATA_PATH,
|
||||
DATA_PATH_IS_NOT_DESCRIPTION
|
||||
|
|
|
@ -210,7 +210,7 @@ void ProfileDialog::updateWidgets()
|
|||
index = index.sibling(index.row(), ProfileModel::COL_NAME);
|
||||
|
||||
if (index.isValid()) {
|
||||
if ( !index.data(ProfileModel::DATA_IS_GLOBAL).toBool() || ! model_->resetDefault())
|
||||
if ( !index.data(ProfileModel::DATA_IS_SYSTEM).toBool() || ! model_->resetDefault())
|
||||
enable_del = true;
|
||||
}
|
||||
|
||||
|
@ -229,11 +229,11 @@ void ProfileDialog::updateWidgets()
|
|||
|
||||
if ( idx != index && idx.data().toString().compare(index.data().toString()) == 0 )
|
||||
{
|
||||
if (idx.data(ProfileModel::DATA_IS_GLOBAL).toBool() == index.data(ProfileModel::DATA_IS_GLOBAL).toBool())
|
||||
if (idx.data(ProfileModel::DATA_IS_SYSTEM).toBool() == index.data(ProfileModel::DATA_IS_SYSTEM).toBool())
|
||||
enable_ok = false;
|
||||
}
|
||||
|
||||
QList<int> rows = model_->findAllByNameAndVisibility(name, idx.data(ProfileModel::DATA_IS_GLOBAL).toBool());
|
||||
QList<int> rows = model_->findAllByNameAndVisibility(name, idx.data(ProfileModel::DATA_IS_SYSTEM).toBool());
|
||||
if ( rows.count() > 1 )
|
||||
enable_ok = false;
|
||||
}
|
||||
|
@ -419,7 +419,7 @@ void ProfileDialog::exportProfiles(bool exportAll)
|
|||
for ( int cnt = 0; cnt < sort_model_->rowCount(); cnt++ )
|
||||
{
|
||||
QModelIndex idx = sort_model_->index(cnt, ProfileModel::COL_NAME);
|
||||
if ( ! idx.data(ProfileModel::DATA_IS_GLOBAL).toBool() && ! idx.data(ProfileModel::DATA_IS_DEFAULT).toBool() )
|
||||
if ( ! idx.data(ProfileModel::DATA_IS_SYSTEM).toBool() && ! idx.data(ProfileModel::DATA_IS_DEFAULT).toBool() )
|
||||
{
|
||||
items << sort_model_->mapToSource(idx);
|
||||
}
|
||||
|
|
|
@ -52,14 +52,14 @@ CopyFromProfileMenu::CopyFromProfileMenu(QString filename, QWidget *parent) :
|
|||
pa = new QAction(name, this);
|
||||
if ( idx.data(ProfileModel::DATA_IS_DEFAULT).toBool() )
|
||||
addAction(pa);
|
||||
else if ( idx.data(ProfileModel::DATA_IS_GLOBAL).toBool() )
|
||||
else if ( idx.data(ProfileModel::DATA_IS_SYSTEM).toBool() )
|
||||
global << pa;
|
||||
else
|
||||
user << pa;
|
||||
|
||||
pa->setFont(idx.data(Qt::FontRole).value<QFont>());
|
||||
pa->setProperty("profile_name", name);
|
||||
pa->setProperty("profile_is_global", idx.data(ProfileModel::DATA_IS_GLOBAL));
|
||||
pa->setProperty("profile_is_system", idx.data(ProfileModel::DATA_IS_SYSTEM));
|
||||
|
||||
pa->setProperty("filename", fi.absoluteFilePath());
|
||||
pa->setData(fi.absoluteFilePath().toUtf8().constData());
|
||||
|
|
|
@ -775,7 +775,7 @@ get_progfile_dir(void)
|
|||
}
|
||||
|
||||
/*
|
||||
* Get the directory in which the global configuration and data files are
|
||||
* Get the directory in which the system configuration and data files are
|
||||
* stored.
|
||||
*
|
||||
* On Windows, we use the directory in which the executable for this
|
||||
|
@ -1135,7 +1135,7 @@ running_in_build_directory(void)
|
|||
/*
|
||||
* Get the directory in which files that, at least on UNIX, are
|
||||
* system files (such as "/etc/ethers") are stored; on Windows,
|
||||
* there's no "/etc" directory, so we get them from the global
|
||||
* there's no "/etc" directory, so we get them from the system
|
||||
* configuration and data file directory.
|
||||
*/
|
||||
const char *
|
||||
|
@ -1179,22 +1179,22 @@ is_default_profile(void)
|
|||
}
|
||||
|
||||
gboolean
|
||||
has_global_profiles(void)
|
||||
has_system_profiles(void)
|
||||
{
|
||||
WS_DIR *dir;
|
||||
WS_DIRENT *file;
|
||||
gchar *global_dir = get_global_profiles_dir();
|
||||
gchar *system_dir = get_system_profiles_dir();
|
||||
gchar *filename;
|
||||
gboolean has_global = FALSE;
|
||||
gboolean has_system = FALSE;
|
||||
|
||||
if ((test_for_directory(global_dir) == EISDIR) &&
|
||||
((dir = ws_dir_open(global_dir, 0, NULL)) != NULL))
|
||||
if ((test_for_directory(system_dir) == EISDIR) &&
|
||||
((dir = ws_dir_open(system_dir, 0, NULL)) != NULL))
|
||||
{
|
||||
while ((file = ws_dir_read_name(dir)) != NULL) {
|
||||
filename = g_strdup_printf ("%s%s%s", global_dir, G_DIR_SEPARATOR_S,
|
||||
filename = g_strdup_printf ("%s%s%s", system_dir, G_DIR_SEPARATOR_S,
|
||||
ws_dir_get_name(file));
|
||||
if (test_for_directory(filename) == EISDIR) {
|
||||
has_global = TRUE;
|
||||
has_system = TRUE;
|
||||
g_free (filename);
|
||||
break;
|
||||
}
|
||||
|
@ -1202,8 +1202,8 @@ has_global_profiles(void)
|
|||
}
|
||||
ws_dir_close(dir);
|
||||
}
|
||||
g_free(global_dir);
|
||||
return has_global;
|
||||
g_free(system_dir);
|
||||
return has_system;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1400,7 +1400,7 @@ create_profiles_dir(char **pf_dir_path_return)
|
|||
}
|
||||
|
||||
char *
|
||||
get_global_profiles_dir(void)
|
||||
get_system_profiles_dir(void)
|
||||
{
|
||||
return g_strdup_printf ("%s%s%s", get_datafile_dir(),
|
||||
G_DIR_SEPARATOR_S, PROFILES_DIR);
|
||||
|
@ -1425,17 +1425,17 @@ get_persconffile_dir(const gchar *profilename)
|
|||
}
|
||||
|
||||
char *
|
||||
get_profile_dir(const char *profilename, gboolean is_global)
|
||||
get_profile_dir(const char *profilename, gboolean is_system)
|
||||
{
|
||||
gchar *profile_dir;
|
||||
|
||||
if (is_global) {
|
||||
if (is_system) {
|
||||
if (profilename && strlen(profilename) > 0 &&
|
||||
strcmp(profilename, DEFAULT_PROFILE) != 0)
|
||||
{
|
||||
gchar *global_path = get_global_profiles_dir();
|
||||
profile_dir = g_build_filename(global_path, profilename, NULL);
|
||||
g_free(global_path);
|
||||
gchar *system_path = get_system_profiles_dir();
|
||||
profile_dir = g_build_filename(system_path, profilename, NULL);
|
||||
g_free(system_path);
|
||||
} else {
|
||||
profile_dir = g_strdup(get_datafile_dir());
|
||||
}
|
||||
|
@ -1451,19 +1451,19 @@ get_profile_dir(const char *profilename, gboolean is_global)
|
|||
}
|
||||
|
||||
gboolean
|
||||
profile_exists(const gchar *profilename, gboolean global)
|
||||
profile_exists(const gchar *profilename, gboolean system)
|
||||
{
|
||||
gchar *path = NULL;
|
||||
gboolean exists;
|
||||
|
||||
/*
|
||||
* If we're looking up a global profile, we must have a
|
||||
* If we're looking up a system profile, we must have a
|
||||
* profile name.
|
||||
*/
|
||||
if (global && !profilename)
|
||||
if (system && !profilename)
|
||||
return FALSE;
|
||||
|
||||
path = get_profile_dir(profilename, global);
|
||||
path = get_profile_dir(profilename, system);
|
||||
exists = (test_for_directory(path) == EISDIR) ? TRUE : FALSE;
|
||||
|
||||
g_free(path);
|
||||
|
@ -1683,7 +1683,7 @@ create_persconffile_dir(char **pf_dir_path_return)
|
|||
}
|
||||
|
||||
int
|
||||
copy_persconffile_profile(const char *toname, const char *fromname, gboolean from_global,
|
||||
copy_persconffile_profile(const char *toname, const char *fromname, gboolean from_system,
|
||||
char **pf_filename_return, char **pf_to_dir_path_return, char **pf_from_dir_path_return)
|
||||
{
|
||||
gchar *from_dir;
|
||||
|
@ -1691,7 +1691,7 @@ copy_persconffile_profile(const char *toname, const char *fromname, gboolean fro
|
|||
gchar *filename, *from_file, *to_file;
|
||||
GList *files, *file;
|
||||
|
||||
from_dir = get_profile_dir(fromname, from_global);
|
||||
from_dir = get_profile_dir(fromname, from_system);
|
||||
|
||||
files = g_hash_table_get_keys(profile_files);
|
||||
file = g_list_first(files);
|
||||
|
@ -1852,7 +1852,7 @@ get_persconffile_path(const char *filename, gboolean from_profile)
|
|||
}
|
||||
|
||||
/*
|
||||
* Construct the path name of a global configuration file, given the
|
||||
* Construct the path name of a system configuration file, given the
|
||||
* file name.
|
||||
*
|
||||
* The returned file name was g_malloc()'d so it must be g_free()d when the
|
||||
|
|
|
@ -72,13 +72,13 @@ WS_DLL_PUBLIC const char *get_extcap_dir(void);
|
|||
WS_DLL_PUBLIC gboolean running_in_build_directory(void);
|
||||
|
||||
/*
|
||||
* Get the directory in which global configuration files are
|
||||
* Get the directory in which system configuration files are
|
||||
* stored.
|
||||
*/
|
||||
WS_DLL_PUBLIC const char *get_datafile_dir(void);
|
||||
|
||||
/*
|
||||
* Construct the path name of a global configuration file, given the
|
||||
* Construct the path name of a system configuration file, given the
|
||||
* file name.
|
||||
*
|
||||
* The returned file name was g_malloc()'d so it must be g_free()d when the
|
||||
|
@ -90,7 +90,7 @@ WS_DLL_PUBLIC char *get_datafile_path(const char *filename);
|
|||
* Get the directory in which files that, at least on UNIX, are
|
||||
* system files (such as "/etc/ethers") are stored; on Windows,
|
||||
* there's no "/etc" directory, so we get them from the Wireshark
|
||||
* global configuration and data file directory.
|
||||
* system configuration and data file directory.
|
||||
*/
|
||||
WS_DLL_PUBLIC const char *get_systemfile_dir(void);
|
||||
|
||||
|
@ -112,9 +112,9 @@ WS_DLL_PUBLIC const char *get_profile_name(void);
|
|||
WS_DLL_PUBLIC gboolean is_default_profile(void);
|
||||
|
||||
/*
|
||||
* Check if we have global profiles.
|
||||
* Check if we have system profiles.
|
||||
*/
|
||||
WS_DLL_PUBLIC gboolean has_global_profiles(void);
|
||||
WS_DLL_PUBLIC gboolean has_system_profiles(void);
|
||||
|
||||
/*
|
||||
* Get the directory used to store configuration profile directories.
|
||||
|
@ -126,7 +126,7 @@ WS_DLL_PUBLIC char *get_profiles_dir(void);
|
|||
* Get the directory used to store configuration files for a given profile.
|
||||
* Caller must free the returned string.
|
||||
*/
|
||||
WS_DLL_PUBLIC char *get_profile_dir(const char *profilename, gboolean is_global);
|
||||
WS_DLL_PUBLIC char *get_profile_dir(const char *profilename, gboolean is_system);
|
||||
|
||||
/*
|
||||
* Create the directory used to store configuration profile directories.
|
||||
|
@ -134,10 +134,10 @@ WS_DLL_PUBLIC char *get_profile_dir(const char *profilename, gboolean is_global)
|
|||
WS_DLL_PUBLIC int create_profiles_dir(char **pf_dir_path_return);
|
||||
|
||||
/*
|
||||
* Get the directory used to store global configuration profile directories.
|
||||
* Get the directory used to store system configuration profile directories.
|
||||
* Caller must free the returned string
|
||||
*/
|
||||
WS_DLL_PUBLIC char *get_global_profiles_dir(void);
|
||||
WS_DLL_PUBLIC char *get_system_profiles_dir(void);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -149,7 +149,7 @@ WS_DLL_PUBLIC void profile_store_persconffiles(gboolean store);
|
|||
/*
|
||||
* Check if given configuration profile exists.
|
||||
*/
|
||||
WS_DLL_PUBLIC gboolean profile_exists(const gchar *profilename, gboolean global);
|
||||
WS_DLL_PUBLIC gboolean profile_exists(const gchar *profilename, gboolean system);
|
||||
|
||||
/*
|
||||
* Create a directory for the given configuration profile.
|
||||
|
@ -182,7 +182,7 @@ WS_DLL_PUBLIC int rename_persconffile_profile(const char *fromname, const char *
|
|||
* Copy files in one profile to the other.
|
||||
*/
|
||||
WS_DLL_PUBLIC int copy_persconffile_profile(const char *toname, const char *fromname,
|
||||
gboolean from_global,
|
||||
gboolean from_system,
|
||||
char **pf_filename_return,
|
||||
char **pf_to_dir_path_return,
|
||||
char **pf_from_dir_path_return);
|
||||
|
|
Loading…
Reference in New Issue