Qt 4.8
Classes | Public Functions | Properties | List of all members
QMacSettingsPrivate Class Reference
Inheritance diagram for QMacSettingsPrivate:
QSettingsPrivate QObjectPrivate QObjectData

Classes

struct  SearchDomain
 

Public Functions

QStringList children (const QString &prefix, ChildSpec spec) const
 
void clear ()
 
QString fileName () const
 
void flush ()
 
bool get (const QString &key, QVariant *value) const
 
bool isWritable () const
 
 QMacSettingsPrivate (QSettings::Scope scope, const QString &organization, const QString &application)
 
 QMacSettingsPrivate (CFStringRef bundleIdentifier)
 
void remove (const QString &key)
 
void set (const QString &key, const QVariant &value)
 
void sync ()
 
 ~QMacSettingsPrivate ()
 
- Public Functions inherited from QSettingsPrivate
QString actualKey (const QString &key) const
 
void beginGroupOrArray (const QSettingsGroup &group)
 
 QSettingsPrivate (QSettings::Format format)
 
 QSettingsPrivate (QSettings::Format format, QSettings::Scope scope, const QString &organization, const QString &application)
 
void requestUpdate ()
 
void setStatus (QSettings::Status status) const
 
void update ()
 
virtual ~QSettingsPrivate ()
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Properties

QCFString applicationId
 
SearchDomain domains [6]
 
QCFString hostName
 
int numDomains
 
QCFString suiteId
 

Additional Inherited Members

- Public Types inherited from QSettingsPrivate
enum  {
  F_Application = 0x0, F_Organization = 0x1, F_User = 0x0, F_System = 0x2,
  NumConfFiles = 4
}
 
enum  ChildSpec { AllKeys, ChildKeys, ChildGroups }
 
- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 
- Static Public Functions inherited from QSettingsPrivate
static QSettingsPrivatecreate (QSettings::Format format, QSettings::Scope scope, const QString &organization, const QString &application)
 
static QSettingsPrivatecreate (const QString &fileName, QSettings::Format format)
 
static void iniEscapedKey (const QString &key, QByteArray &result)
 
static void iniEscapedString (const QString &str, QByteArray &result, QTextCodec *codec)
 
static void iniEscapedStringList (const QStringList &strs, QByteArray &result, QTextCodec *codec)
 
static bool iniUnescapedKey (const QByteArray &key, int from, int to, QString &result)
 
static bool iniUnescapedStringList (const QByteArray &str, int from, int to, QString &stringResult, QStringList &stringListResult, QTextCodec *codec)
 
static QString normalizedKey (const QString &key)
 
static void processChild (QString key, ChildSpec spec, QMap< QString, QString > &result)
 
static QStringList splitArgs (const QString &s, int idx)
 
static QVariant stringListToVariantList (const QStringList &l)
 
static QVariant stringToVariant (const QString &s)
 
static QStringList variantListToStringList (const QVariantList &l)
 
static QString variantToString (const QVariant &v)
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 
- Public Variables inherited from QSettingsPrivate
QString applicationName
 
QSettings::Format format
 
QTextCodeciniCodec
 
QString organizationName
 
QSettings::Scope scope
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 
- Protected Variables inherited from QSettingsPrivate
bool fallbacks
 
QString groupPrefix
 
QStack< QSettingsGroupgroupStack
 
bool pendingChanges
 
int spec
 
QSettings::Status status
 

Detailed Description

Definition at line 348 of file qsettings_mac.cpp.

Constructors and Destructors

◆ QMacSettingsPrivate() [1/2]

QMacSettingsPrivate::QMacSettingsPrivate ( QSettings::Scope  scope,
const QString organization,
const QString application 
)

Definition at line 380 of file qsettings_mac.cpp.

Referenced by QSettingsPrivate::create().

382  : QSettingsPrivate(QSettings::NativeFormat, scope, organization, application)
383 {
384  QString javaPackageName;
385  int curPos = 0;
386  int nextDot;
387 
388  QString domainName = comify(organization);
389  if (domainName.isEmpty()) {
391  domainName = QLatin1String("unknown-organization.trolltech.com");
392  }
393 
394  while ((nextDot = domainName.indexOf(QLatin1Char('.'), curPos)) != -1) {
395  javaPackageName.prepend(domainName.mid(curPos, nextDot - curPos));
396  javaPackageName.prepend(QLatin1Char('.'));
397  curPos = nextDot + 1;
398  }
399  javaPackageName.prepend(domainName.mid(curPos));
400  javaPackageName = javaPackageName.toLower();
401  if (curPos == 0)
402  javaPackageName.prepend(QLatin1String("com."));
403  suiteId = javaPackageName;
404 
406  spec |= F_System;
407 
408  if (application.isEmpty()) {
409  spec |= F_Organization;
410  } else {
411  javaPackageName += QLatin1Char('.');
412  javaPackageName += application;
413  applicationId = javaPackageName;
414  }
415 
416  numDomains = 0;
417  for (int i = (spec & F_System) ? 1 : 0; i < 2; ++i) {
418  for (int j = (spec & F_Organization) ? 1 : 0; j < 3; ++j) {
419  SearchDomain &domain = domains[numDomains++];
420  domain.userName = (i == 0) ? kCFPreferencesCurrentUser : kCFPreferencesAnyUser;
421  if (j == 0)
422  domain.applicationOrSuiteId = applicationId;
423  else if (j == 1)
424  domain.applicationOrSuiteId = suiteId;
425  else
426  domain.applicationOrSuiteId = kCFPreferencesAnyApplication;
427  }
428  }
429 
430  hostName = (scope == QSettings::SystemScope) ? kCFPreferencesCurrentHost : kCFPreferencesAnyHost;
431  sync();
432 }
SearchDomain domains[6]
void setStatus(QSettings::Status status) const
Definition: qsettings.cpp:410
QSettingsPrivate(QSettings::Format format)
Definition: qsettings.cpp:302
static QString comify(const QString &organization)
QString & prepend(QChar c)
Definition: qstring.h:261
QSettings::Scope scope
Definition: qsettings_p.h:259
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
Definition: qstring.cpp:5389
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ QMacSettingsPrivate() [2/2]

QMacSettingsPrivate::QMacSettingsPrivate ( CFStringRef  bundleIdentifier)

Definition at line 434 of file qsettings_mac.cpp.

436 {
437  // applicationId and suiteId are QCFStrings and take ownership, retain to prevent double deletes.
438  CFRetain(bundleIdentifier);
439  applicationId = bundleIdentifier;
440  CFRetain(bundleIdentifier);
441  suiteId = bundleIdentifier;
442 
443  numDomains = 1;
444  domains[0].userName = kCFPreferencesCurrentUser;
445  domains[0].applicationOrSuiteId = bundleIdentifier;
446  hostName = kCFPreferencesAnyHost;
447  sync();
448 }
SearchDomain domains[6]
QSettingsPrivate(QSettings::Format format)
Definition: qsettings.cpp:302
The QString class provides a Unicode character string.
Definition: qstring.h:83

◆ ~QMacSettingsPrivate()

QMacSettingsPrivate::~QMacSettingsPrivate ( )

Definition at line 450 of file qsettings_mac.cpp.

451 {
452 }

Functions

◆ children()

QStringList QMacSettingsPrivate::children ( const QString prefix,
ChildSpec  spec 
) const
virtual

Implements QSettingsPrivate.

Definition at line 497 of file qsettings_mac.cpp.

Referenced by remove().

498 {
499  QMap<QString, QString> result;
500  int startPos = prefix.size();
501 
502  for (int i = 0; i < numDomains; ++i) {
503  for (int j = 0; j < numHostNames; ++j) {
504  QCFType<CFArrayRef> cfarray = CFPreferencesCopyKeyList(domains[i].applicationOrSuiteId,
505  domains[i].userName,
506  hostNames[j]);
507  if (cfarray) {
508  CFIndex size = CFArrayGetCount(cfarray);
509  for (CFIndex k = 0; k < size; ++k) {
510  QString currentKey =
511  qtKey(static_cast<CFStringRef>(CFArrayGetValueAtIndex(cfarray, k)));
512  if (currentKey.startsWith(prefix))
513  processChild(currentKey.mid(startPos), spec, result);
514  }
515  }
516  }
517 
518  if (!fallbacks)
519  break;
520  }
521  return result.keys();
522 }
SearchDomain domains[6]
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
The QString class provides a Unicode character string.
Definition: qstring.h:83
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
static const int numHostNames
QList< Key > keys() const
Returns a list containing all the keys in the map in ascending order.
Definition: qmap.h:818
static const CFStringRef hostNames[2]
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
static QString qtKey(CFStringRef cfkey)
static void processChild(QString key, ChildSpec spec, QMap< QString, QString > &result)
Definition: qsettings.cpp:380

◆ clear()

void QMacSettingsPrivate::clear ( )
virtual

Implements QSettingsPrivate.

Definition at line 524 of file qsettings_mac.cpp.

525 {
526  QCFType<CFArrayRef> cfarray = CFPreferencesCopyKeyList(domains[0].applicationOrSuiteId,
527  domains[0].userName, hostName);
528  CFPreferencesSetMultiple(0, cfarray, domains[0].applicationOrSuiteId, domains[0].userName,
529  hostName);
530 }
SearchDomain domains[6]

◆ fileName()

QString QMacSettingsPrivate::fileName ( ) const
virtual

Implements QSettingsPrivate.

Definition at line 590 of file qsettings_mac.cpp.

591 {
592  QString result;
593  if ((spec & F_System) == 0)
594  result = QDir::homePath();
595  result += QLatin1String("/Library/Preferences/");
596  result += QCFString::toQString(domains[0].applicationOrSuiteId);
597  result += QLatin1String(".plist");
598  return result;
599 }
SearchDomain domains[6]
static QString toQString(CFStringRef cfstr)
Definition: qcore_mac.cpp:47
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QString homePath()
Returns the absolute path of the user&#39;s home directory.
Definition: qdir.cpp:1942

◆ flush()

void QMacSettingsPrivate::flush ( )
virtual

Implements QSettingsPrivate.

Definition at line 567 of file qsettings_mac.cpp.

568 {
569  sync();
570 }

◆ get()

bool QMacSettingsPrivate::get ( const QString key,
QVariant value 
) const
virtual

Implements QSettingsPrivate.

Definition at line 476 of file qsettings_mac.cpp.

Referenced by isWritable().

477 {
478  QCFString k = macKey(key);
479  for (int i = 0; i < numDomains; ++i) {
480  for (int j = 0; j < numHostNames; ++j) {
482  CFPreferencesCopyValue(k, domains[i].applicationOrSuiteId, domains[i].userName,
483  hostNames[j]);
484  if (ret) {
485  if (value)
486  *value = qtValue(ret);
487  return true;
488  }
489  }
490 
491  if (!fallbacks)
492  break;
493  }
494  return false;
495 }
SearchDomain domains[6]
static QVariant qtValue(CFPropertyListRef cfvalue)
static QCFType< CFStringRef > macKey(const QString &key)
static const int numHostNames
static const CFStringRef hostNames[2]

◆ isWritable()

bool QMacSettingsPrivate::isWritable ( ) const
virtual

Implements QSettingsPrivate.

Definition at line 572 of file qsettings_mac.cpp.

573 {
574  QMacSettingsPrivate *that = const_cast<QMacSettingsPrivate *>(this);
575  QString impossibleKey(QLatin1String("qt_internal/"));
576 
577  QSettings::Status oldStatus = that->status;
578  that->status = QSettings::NoError;
579 
580  that->set(impossibleKey, QVariant());
581  that->sync();
582  bool writable = (status == QSettings::NoError) && that->get(impossibleKey, 0);
583  that->remove(impossibleKey);
584  that->sync();
585 
586  that->status = oldStatus;
587  return writable;
588 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
bool get(const QString &key, QVariant *value) const
Status
The following status values are possible:
Definition: qsettings.h:86
void set(const QString &key, const QVariant &value)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void remove(const QString &key)
The QString class provides a Unicode character string.
Definition: qstring.h:83
QSettings::Status status
Definition: qsettings_p.h:270

◆ remove()

void QMacSettingsPrivate::remove ( const QString key)
virtual

Implements QSettingsPrivate.

Definition at line 454 of file qsettings_mac.cpp.

Referenced by isWritable().

455 {
457 
458  // If i == -1, then delete "key" itself.
459  for (int i = -1; i < keys.size(); ++i) {
460  QString subKey = key;
461  if (i >= 0) {
462  subKey += QLatin1Char('/');
463  subKey += keys.at(i);
464  }
465  CFPreferencesSetValue(macKey(subKey), 0, domains[0].applicationOrSuiteId,
466  domains[0].userName, hostName);
467  }
468 }
SearchDomain domains[6]
static QCFType< CFStringRef > macKey(const QString &key)
The QString class provides a Unicode character string.
Definition: qstring.h:83
QStringList keys
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
int key
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
QStringList children(const QString &prefix, ChildSpec spec) const

◆ set()

void QMacSettingsPrivate::set ( const QString key,
const QVariant value 
)
virtual

Implements QSettingsPrivate.

Definition at line 470 of file qsettings_mac.cpp.

Referenced by isWritable().

471 {
472  CFPreferencesSetValue(macKey(key), macValue(value), domains[0].applicationOrSuiteId,
473  domains[0].userName, hostName);
474 }
SearchDomain domains[6]
static QCFType< CFStringRef > macKey(const QString &key)
static QCFType< CFPropertyListRef > macValue(const QVariant &value)

◆ sync()

void QMacSettingsPrivate::sync ( )
virtual

Implements QSettingsPrivate.

Definition at line 532 of file qsettings_mac.cpp.

Referenced by flush(), isWritable(), and QMacSettingsPrivate().

533 {
534  for (int i = 0; i < numDomains; ++i) {
535  for (int j = 0; j < numHostNames; ++j) {
536  Boolean ok = CFPreferencesSynchronize(domains[i].applicationOrSuiteId,
537  domains[i].userName, hostNames[j]);
538  // only report failures for the primary file (the one we write to)
539  if (!ok && i == 0 && hostNames[j] == hostName && status == QSettings::NoError) {
540 #if 1
541  // work around what seems to be a bug in CFPreferences:
542  // don't report an error if there are no preferences for the application
543  QCFType<CFArrayRef> appIds = CFPreferencesCopyApplicationList(domains[i].userName,
544  hostNames[j]);
545 
546  // iterate through all the applications and see if we're there
547  CFIndex size = CFArrayGetCount(appIds);
548  for (CFIndex k = 0; k < size; ++k) {
549  const void *cfvalue = CFArrayGetValueAtIndex(appIds, k);
550  if (CFGetTypeID(cfvalue) == CFStringGetTypeID()) {
551  if (CFStringCompare(static_cast<CFStringRef>(cfvalue),
552  domains[i].applicationOrSuiteId,
553  kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
555  break;
556  }
557  }
558  }
559 #else
561 #endif
562  }
563  }
564  }
565 }
SearchDomain domains[6]
void setStatus(QSettings::Status status) const
Definition: qsettings.cpp:410
static const int numHostNames
static const CFStringRef hostNames[2]
QSettings::Status status
Definition: qsettings_p.h:270

Properties

◆ applicationId

QCFString QMacSettingsPrivate::applicationId
private

Definition at line 373 of file qsettings_mac.cpp.

Referenced by QMacSettingsPrivate().

◆ domains

SearchDomain QMacSettingsPrivate::domains[6]
private

Definition at line 376 of file qsettings_mac.cpp.

Referenced by children(), clear(), fileName(), get(), QMacSettingsPrivate(), remove(), set(), and sync().

◆ hostName

QCFString QMacSettingsPrivate::hostName
private

Definition at line 375 of file qsettings_mac.cpp.

Referenced by clear(), QMacSettingsPrivate(), remove(), set(), and sync().

◆ numDomains

int QMacSettingsPrivate::numDomains
private

Definition at line 377 of file qsettings_mac.cpp.

Referenced by children(), get(), QMacSettingsPrivate(), and sync().

◆ suiteId

QCFString QMacSettingsPrivate::suiteId
private

Definition at line 374 of file qsettings_mac.cpp.

Referenced by QMacSettingsPrivate().


The documentation for this class was generated from the following file: