Qt 4.8
Public Slots | Public Functions | Public Variables | Private Functions | Properties | List of all members
QBBSystemLocaleData Class Reference

#include <qlocale_blackberry.h>

Inheritance diagram for QBBSystemLocaleData:
QObject

Public Slots

void installSocketNotifiers ()
 
void readHourFormat ()
 
void readLangageLocale ()
 
void readMeasurementSystem ()
 
void readRegionLocale ()
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 

Public Functions

QVariant dateTimeFormat (QLocale::FormatType)
 
QLocale languageLocale ()
 
uint measurementSystem ()
 
 QBBSystemLocaleData ()
 
QLocale regionLocale ()
 
QVariant timeFormat (QLocale::FormatType)
 
virtual ~QBBSystemLocaleData ()
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Public Variables

QReadWriteLock lock
 

Private Functions

QString getCorrectFormat (const QString &baseFormat, QLocale::FormatType typeFormat)
 
QByteArray readPpsValue (const char *ppsObject, int ppsFd)
 

Properties

int hourFd
 
QSocketNotifierhourNotifier
 
bool is24HourFormat
 
int languageFd
 
QSocketNotifierlanguageNotifier
 
QByteArray lc_langage
 
QByteArray lc_region
 
uint m_measurementSystem
 
int measurementFd
 
QSocketNotifiermeasurementNotifier
 
int regionFd
 
QSocketNotifierregionNotifier
 

Additional Inherited Members

- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 57 of file qlocale_blackberry.h.

Constructors and Destructors

◆ QBBSystemLocaleData()

QBBSystemLocaleData::QBBSystemLocaleData ( )

Definition at line 65 of file qlocale_blackberry.cpp.

66  : languageNotifier(0)
67  , regionNotifier(0)
69  , hourNotifier(0)
70 {
71  // Do not use qWarning to log warnings if qt_safe_open fails to open the pps file
72  // since the user code may install a message handler that invokes QLocale API again
73  // (i.e QDate, QDateTime, ...) which will cause an infinite loop.
75  fprintf(stderr, "Failed to open uom pps, errno=%d\n", errno);
76 
78  fprintf(stderr, "Failed to open region pps, errno=%d\n", errno);
79 
81  fprintf(stderr, "Failed to open language pps, errno=%d\n", errno);
82 
84  fprintf(stderr, "Failed to open hour format pps, errno=%d\n", errno);
85 
86  // we cannot call this directly, because by the time this constructor is
87  // called, the event dispatcher has not yet been created, causing the
88  // subsequent call to QSocketNotifier constructor to fail.
89  QMetaObject::invokeMethod(this, "installSocketNotifiers", Qt::QueuedConnection);
90 
95 }
QSocketNotifier * languageNotifier
static const char ppsHourFormatPath[]
#define O_RDONLY
QSocketNotifier * measurementNotifier
static int qt_safe_open(const char *pathname, int flags, mode_t mode=0777)
Definition: qcore_unix_p.h:171
static const char ppsUomPath[]
QSocketNotifier * hourNotifier
static const char ppsRegionLocalePath[]
static bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType, QGenericReturnArgument ret, QGenericArgument val0=QGenericArgument(0), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument())
Invokes the member (a signal or a slot name) on the object obj.
static const char ppsLanguageLocalePath[]
QSocketNotifier * regionNotifier
int errno

◆ ~QBBSystemLocaleData()

QBBSystemLocaleData::~QBBSystemLocaleData ( )
virtual

Definition at line 97 of file qlocale_blackberry.cpp.

98 {
99  if (measurementFd != -1)
101 
102  if (languageFd != -1)
104 
105  if (regionFd != -1)
107 
108  if (hourFd != -1)
110 }
static int qt_safe_close(int fd)
Definition: qcore_unix_p.h:297

Functions

◆ dateTimeFormat()

QVariant QBBSystemLocaleData::dateTimeFormat ( QLocale::FormatType  formatType)

Definition at line 122 of file qlocale_blackberry.cpp.

Referenced by QSystemLocale::query().

123 {
125 }
QString formatType(const NamePool::Ptr &np, const T &type)
Formats ItemType and SequenceType.
QString getCorrectFormat(const QString &baseFormat, QLocale::FormatType typeFormat)
QVariant dateTimeFormat(QLocale::FormatType)

◆ getCorrectFormat()

QString QBBSystemLocaleData::getCorrectFormat ( const QString baseFormat,
QLocale::FormatType  typeFormat 
)
private

Definition at line 238 of file qlocale_blackberry.cpp.

Referenced by dateTimeFormat(), and timeFormat().

239 {
240  QString format = baseFormat;
241  if (is24HourFormat) {
242  if (format.contains(QLatin1String("AP"), Qt::CaseInsensitive)) {
245  }
246 
247  } else {
248 
249  if (!format.contains(QLatin1String("AP"), Qt::CaseInsensitive)) {
250  format.contains(QLatin1String("HH"), Qt::CaseSensitive) ?
251  format.replace(QLatin1String("HH"), QLatin1String("hh"), Qt::CaseSensitive) :
253 
254  formatType == QLocale::LongFormat ? format.append(QLatin1String(" AP t")) : format.append(QLatin1String(" AP"));
255  }
256  }
257 
258  return format;
259 }
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:904
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005
QString formatType(const NamePool::Ptr &np, const T &type)
Formats ItemType and SequenceType.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
QString & append(QChar c)
Definition: qstring.cpp:1777

◆ installSocketNotifiers

void QBBSystemLocaleData::installSocketNotifiers ( )
slot

Definition at line 143 of file qlocale_blackberry.cpp.

144 {
147 
149  QObject::connect(languageNotifier, SIGNAL(activated(int)), this, SLOT(readLangageLocale()));
150 
152  QObject::connect(regionNotifier, SIGNAL(activated(int)), this, SLOT(readRegionLocale()));
153 
156 
158  QObject::connect(hourNotifier, SIGNAL(activated(int)), this, SLOT(readHourFormat()));
159 }
QSocketNotifier * languageNotifier
#define SLOT(a)
Definition: qobjectdefs.h:226
QSocketNotifier * measurementNotifier
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QSocketNotifier class provides support for monitoring activity on a file descriptor.
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
QSocketNotifier * hourNotifier
static QCoreApplication * instance()
Returns a pointer to the application&#39;s QCoreApplication (or QApplication) instance.
QSocketNotifier * regionNotifier

◆ languageLocale()

QLocale QBBSystemLocaleData::languageLocale ( )

Definition at line 127 of file qlocale_blackberry.cpp.

Referenced by QSystemLocale::query().

128 {
129  if (!lc_langage.isEmpty())
131 
132  return QLocale::c();
133 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QLocale c()
Returns a QLocale object initialized to the "C" locale.
Definition: qlocale.h:773
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421

◆ measurementSystem()

uint QBBSystemLocaleData::measurementSystem ( )

Definition at line 112 of file qlocale_blackberry.cpp.

Referenced by QSystemLocale::query().

113 {
114  return m_measurementSystem;
115 }

◆ readHourFormat

void QBBSystemLocaleData::readHourFormat ( )
slot

Definition at line 177 of file qlocale_blackberry.cpp.

Referenced by installSocketNotifiers(), and QBBSystemLocaleData().

178 {
179  QByteArray hourFormat = readPpsValue("hourFormat", hourFd);
180  is24HourFormat = (qstrcmp(hourFormat, "24") == 0);
181 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QByteArray readPpsValue(const char *ppsObject, int ppsFd)
int qstrcmp(const QByteArray &str1, const char *str2)
Definition: qbytearray.cpp:336

◆ readLangageLocale

void QBBSystemLocaleData::readLangageLocale ( )
slot

Definition at line 161 of file qlocale_blackberry.cpp.

Referenced by installSocketNotifiers(), and QBBSystemLocaleData().

162 {
163  lc_langage = readPpsValue("_CS_LOCALE", languageFd);
164 }
QByteArray readPpsValue(const char *ppsObject, int ppsFd)

◆ readMeasurementSystem

void QBBSystemLocaleData::readMeasurementSystem ( )
slot

Definition at line 171 of file qlocale_blackberry.cpp.

Referenced by installSocketNotifiers(), and QBBSystemLocaleData().

172 {
173  QByteArray measurement = readPpsValue("uom", measurementFd);
174  m_measurementSystem = (qstrcmp(measurement, "imperial") == 0) ? QLocale::ImperialSystem : QLocale::MetricSystem;
175 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QByteArray readPpsValue(const char *ppsObject, int ppsFd)
int qstrcmp(const QByteArray &str1, const char *str2)
Definition: qbytearray.cpp:336

◆ readPpsValue()

QByteArray QBBSystemLocaleData::readPpsValue ( const char *  ppsObject,
int  ppsFd 
)
private

Definition at line 183 of file qlocale_blackberry.cpp.

Referenced by readHourFormat(), readLangageLocale(), readMeasurementSystem(), and readRegionLocale().

184 {
185  QByteArray result;
186  if (!ppsObject || ppsFd == -1)
187  return result;
188 
189 
190  // PPS objects are of unknown size, but must be read all at once.
191  // Relying on the file size may not be a good idea since the size may change before reading.
192  // Let's try with an initial size (512), and if the buffer is too small try with bigger one,
193  // until we succeed or until other non buffer-size-related error occurs.
194  // Using QVarLengthArray means the first try (of size == 512) uses a buffer on the stack - no allocation necessary.
195  // Hopefully that covers most use cases.
196  int bytes;
198  for (;;) {
199  errno = 0;
200  bytes = qt_safe_read(ppsFd, buffer.data(), buffer.capacity() - 1);
201  const bool bufferIsTooSmall = (bytes == -1 && errno == EMSGSIZE && buffer.capacity() < MAX_PPS_SIZE);
202  if (!bufferIsTooSmall)
203  break;
204 
205  buffer.resize(qMin(buffer.capacity()*2, MAX_PPS_SIZE));
206  }
207 
208  // This method is called in the ctor(), so do not use qWarning to log warnings
209  // if qt_safe_read fails to read the pps file
210  // since the user code may install a message handler that invokes QLocale API again
211  // (i.e QDate, QDateTime, ...) which will cause a infinite loop.
212  if (bytes == -1) {
213  fprintf(stderr, "Failed to read pps object:%s, errno=%d\n", ppsObject, errno);
214  return result;
215  }
216  // ensure data is null terminated
217  buffer[bytes] = '\0';
218 
219  pps_decoder_t ppsDecoder;
220  pps_decoder_initialize(&ppsDecoder, 0);
221  if (pps_decoder_parse_pps_str(&ppsDecoder, buffer.data()) == PPS_DECODER_OK) {
222  pps_decoder_push(&ppsDecoder, 0);
223  const char *ppsBuff;
224  if (pps_decoder_get_string(&ppsDecoder, ppsObject, &ppsBuff) == PPS_DECODER_OK) {
225  result = ppsBuff;
226  } else {
227  int val;
228  if (pps_decoder_get_int(&ppsDecoder, ppsObject, &val) == PPS_DECODER_OK)
229  result = QByteArray::number(val);
230  }
231  }
232 
233  pps_decoder_cleanup(&ppsDecoder);
234 
235  return result;
236 }
void resize(int size)
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static const int MAX_PPS_SIZE
int capacity() const
static QByteArray number(int, int base=10)
Returns a byte array containing the string equivalent of the number n to base base (10 by default)...
static qint64 qt_safe_read(int fd, void *data, qint64 maxlen)
Definition: qcore_unix_p.h:273
int errno

◆ readRegionLocale

void QBBSystemLocaleData::readRegionLocale ( )
slot

Definition at line 166 of file qlocale_blackberry.cpp.

Referenced by installSocketNotifiers(), and QBBSystemLocaleData().

167 {
168  lc_region = readPpsValue("region", regionFd);
169 }
QByteArray readPpsValue(const char *ppsObject, int ppsFd)

◆ regionLocale()

QLocale QBBSystemLocaleData::regionLocale ( )

Definition at line 135 of file qlocale_blackberry.cpp.

Referenced by dateTimeFormat(), QSystemLocale::query(), and timeFormat().

136 {
137  if (!lc_region.isEmpty())
139 
140  return QLocale::c();
141 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QLocale c()
Returns a QLocale object initialized to the "C" locale.
Definition: qlocale.h:773
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421

◆ timeFormat()

QVariant QBBSystemLocaleData::timeFormat ( QLocale::FormatType  formatType)

Definition at line 117 of file qlocale_blackberry.cpp.

Referenced by QSystemLocale::query().

118 {
120 }
QString formatType(const NamePool::Ptr &np, const T &type)
Formats ItemType and SequenceType.
QVariant timeFormat(QLocale::FormatType)
QString getCorrectFormat(const QString &baseFormat, QLocale::FormatType typeFormat)

Properties

◆ hourFd

int QBBSystemLocaleData::hourFd
private

◆ hourNotifier

QSocketNotifier* QBBSystemLocaleData::hourNotifier
private

Definition at line 91 of file qlocale_blackberry.h.

Referenced by installSocketNotifiers().

◆ is24HourFormat

bool QBBSystemLocaleData::is24HourFormat
private

Definition at line 86 of file qlocale_blackberry.h.

Referenced by getCorrectFormat(), and readHourFormat().

◆ languageFd

int QBBSystemLocaleData::languageFd
private

◆ languageNotifier

QSocketNotifier* QBBSystemLocaleData::languageNotifier
private

Definition at line 88 of file qlocale_blackberry.h.

Referenced by installSocketNotifiers().

◆ lc_langage

QByteArray QBBSystemLocaleData::lc_langage
private

Definition at line 83 of file qlocale_blackberry.h.

Referenced by languageLocale(), and readLangageLocale().

◆ lc_region

QByteArray QBBSystemLocaleData::lc_region
private

Definition at line 84 of file qlocale_blackberry.h.

Referenced by QSystemLocale::query(), readRegionLocale(), and regionLocale().

◆ lock

QReadWriteLock QBBSystemLocaleData::lock

Definition at line 70 of file qlocale_blackberry.h.

Referenced by QSystemLocale::query().

◆ m_measurementSystem

uint QBBSystemLocaleData::m_measurementSystem
private

Definition at line 85 of file qlocale_blackberry.h.

Referenced by measurementSystem(), and readMeasurementSystem().

◆ measurementFd

int QBBSystemLocaleData::measurementFd
private

◆ measurementNotifier

QSocketNotifier* QBBSystemLocaleData::measurementNotifier
private

Definition at line 90 of file qlocale_blackberry.h.

Referenced by installSocketNotifiers().

◆ regionFd

int QBBSystemLocaleData::regionFd
private

◆ regionNotifier

QSocketNotifier* QBBSystemLocaleData::regionNotifier
private

Definition at line 89 of file qlocale_blackberry.h.

Referenced by installSocketNotifiers().


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