src/systeminfo/qsysteminfo_mac_p.h
changeset 0 876b1a06bc25
equal deleted inserted replaced
-1:000000000000 0:876b1a06bc25
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt Mobility Components.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 #ifndef QSYSTEMINFO_MAC_P_H
       
    42 #define QSYSTEMINFO_MAC_P_H
       
    43 
       
    44 
       
    45 //
       
    46 //  W A R N I N G
       
    47 //  -------------
       
    48 //
       
    49 // This file is not part of the Qt API.  It exists purely as an
       
    50 // implementation detail.  This header file may change from version to
       
    51 // version without notice, or even be removed.
       
    52 //
       
    53 // We mean it.
       
    54 //
       
    55 
       
    56 
       
    57 #include <QObject>
       
    58 #include <QSize>
       
    59 #include <QHash>
       
    60 
       
    61 #include "qsysteminfo.h"
       
    62 #include <qmobilityglobal.h>
       
    63 
       
    64 #include <QTimer>
       
    65 #include <QtCore/qthread.h>
       
    66 #include <QtCore/qmutex.h>
       
    67 #include <QEventLoop>
       
    68 #include <IOKit/IOKitLib.h>
       
    69 
       
    70 #include <SystemConfiguration/SystemConfiguration.h>
       
    71 //#include <CoreFoundation/CoreFoundation.h>
       
    72 
       
    73 QT_BEGIN_HEADER
       
    74 
       
    75 QT_BEGIN_NAMESPACE
       
    76 class QStringList;
       
    77 class QTimer;
       
    78 QT_END_NAMESPACE
       
    79 
       
    80 QTM_BEGIN_NAMESPACE
       
    81 
       
    82 class QSystemNetworkInfo;
       
    83 
       
    84 class QLangLoopThread;
       
    85 
       
    86 class QSystemInfoPrivate : public QObject
       
    87 {
       
    88     Q_OBJECT
       
    89 
       
    90 public:
       
    91 
       
    92     QSystemInfoPrivate(QObject *parent = 0);
       
    93     virtual ~QSystemInfoPrivate();
       
    94     QString currentLanguage() const;
       
    95     QStringList availableLanguages() const;
       
    96 
       
    97     QString version(QSystemInfo::Version,  const QString &parameter = QString());
       
    98 
       
    99     QString currentCountryCode() const;
       
   100     bool hasFeatureSupported(QSystemInfo::Feature feature);
       
   101     void languageChanged(const QString &);
       
   102     static QSystemInfoPrivate *instance() {return self;}
       
   103 
       
   104 Q_SIGNALS:
       
   105     void currentLanguageChanged(const QString &);
       
   106 
       
   107 private:
       
   108     QTimer *langTimer;
       
   109     QString langCached;
       
   110     QLangLoopThread * langloopThread;
       
   111     static QSystemInfoPrivate *self;
       
   112     bool langThreadOk;
       
   113 
       
   114 protected:
       
   115     void connectNotify(const char *signal);
       
   116     void disconnectNotify(const char *signal);
       
   117 
       
   118 };
       
   119 
       
   120 class QRunLoopThread;
       
   121 class QSystemNetworkInfoPrivate : public QObject
       
   122 {
       
   123     Q_OBJECT
       
   124 
       
   125 public:
       
   126 
       
   127     QSystemNetworkInfoPrivate(QObject *parent = 0);
       
   128     virtual ~QSystemNetworkInfoPrivate();
       
   129 
       
   130     QSystemNetworkInfo::NetworkStatus networkStatus(QSystemNetworkInfo::NetworkMode mode);
       
   131     qint32 networkSignalStrength(QSystemNetworkInfo::NetworkMode mode);
       
   132     int cellId();
       
   133     int locationAreaCode();
       
   134 
       
   135     QString currentMobileCountryCode();
       
   136     QString currentMobileNetworkCode();
       
   137 
       
   138     QString homeMobileCountryCode();
       
   139     QString homeMobileNetworkCode();
       
   140 
       
   141     QString networkName(QSystemNetworkInfo::NetworkMode mode);
       
   142     QString macAddress(QSystemNetworkInfo::NetworkMode mode);
       
   143 
       
   144     QNetworkInterface interfaceForMode(QSystemNetworkInfo::NetworkMode mode);
       
   145     static QSystemNetworkInfoPrivate *instance() {return self;}
       
   146     void wifiNetworkChanged(const QString &notification, const QString interfaceName);
       
   147     QString getDefaultInterface();
       
   148     QSystemNetworkInfo::NetworkMode currentMode();
       
   149     void ethernetChanged();
       
   150 
       
   151 
       
   152 Q_SIGNALS:
       
   153    void networkStatusChanged(QSystemNetworkInfo::NetworkMode, QSystemNetworkInfo::NetworkStatus);
       
   154    void networkSignalStrengthChanged(QSystemNetworkInfo::NetworkMode,int);
       
   155    void currentMobileCountryCodeChanged(const QString &);
       
   156    void currentMobileNetworkCodeChanged(const QString &);
       
   157    void networkNameChanged(QSystemNetworkInfo::NetworkMode, const QString &);
       
   158    void networkModeChanged(QSystemNetworkInfo::NetworkMode);
       
   159 
       
   160 public Q_SLOTS:
       
   161    void primaryInterface();
       
   162 
       
   163 private:
       
   164     QTimer *rssiTimer;
       
   165     int signalStrengthCache;
       
   166     static QSystemNetworkInfoPrivate *self;
       
   167     QRunLoopThread * runloopThread;
       
   168     QString defaultInterface;
       
   169     QSystemNetworkInfo::NetworkMode modeForInterface(QString interfaceName);
       
   170 
       
   171 private Q_SLOTS:
       
   172     void rssiTimeout();
       
   173 protected:
       
   174     void startNetworkChangeLoop();
       
   175     bool isInterfaceActive(const char* netInterface);
       
   176 
       
   177     void connectNotify(const char *signal);
       
   178     void disconnectNotify(const char *signal);
       
   179     bool hasWifi;
       
   180 
       
   181 };
       
   182 
       
   183 class QSystemDisplayInfoPrivate : public QObject
       
   184 {
       
   185     Q_OBJECT
       
   186 
       
   187 public:
       
   188 
       
   189     QSystemDisplayInfoPrivate(QObject *parent = 0);
       
   190     virtual ~QSystemDisplayInfoPrivate();
       
   191 
       
   192     int displayBrightness(int screen);
       
   193     int colorDepth(int screen);
       
   194 };
       
   195 
       
   196 class QSystemStorageInfoPrivate : public QObject
       
   197 {
       
   198     Q_OBJECT
       
   199 
       
   200 public:
       
   201 
       
   202     QSystemStorageInfoPrivate(QObject *parent = 0);
       
   203     virtual ~QSystemStorageInfoPrivate();
       
   204 
       
   205     qint64 availableDiskSpace(const QString &driveVolume);
       
   206     qint64 totalDiskSpace(const QString &driveVolume);
       
   207     QStringList logicalDrives();
       
   208     QSystemStorageInfo::DriveType typeForDrive(const QString &driveVolume);
       
   209 
       
   210 private:
       
   211     QHash<QString, QString> mountEntriesHash;
       
   212     bool updateVolumesMap();
       
   213     void mountEntries();
       
   214 
       
   215 };
       
   216 
       
   217 class QBluetoothListenerThread;
       
   218 class QSystemDeviceInfoPrivate : public QObject
       
   219 {
       
   220     Q_OBJECT
       
   221 
       
   222 public:
       
   223 
       
   224     QSystemDeviceInfoPrivate(QObject *parent = 0);
       
   225     ~QSystemDeviceInfoPrivate();
       
   226 
       
   227     static QString imei();
       
   228     static QString imsi();
       
   229     static QString manufacturer();
       
   230     static QString model();
       
   231     static QString productName();
       
   232 
       
   233     QSystemDeviceInfo::InputMethodFlags inputMethodType();
       
   234 
       
   235     int  batteryLevel();
       
   236 
       
   237     QSystemDeviceInfo::SimStatus simStatus();
       
   238     bool isDeviceLocked();
       
   239     QSystemDeviceInfo::Profile currentProfile();
       
   240 
       
   241     QSystemDeviceInfo::PowerState currentPowerState();
       
   242     void setConnection();
       
   243     static QSystemDeviceInfoPrivate *instance();
       
   244 
       
   245     bool currentBluetoothPowerState();
       
   246     bool btThreadOk;
       
   247 
       
   248 Q_SIGNALS:
       
   249     void batteryLevelChanged(int);
       
   250     void batteryStatusChanged(QSystemDeviceInfo::BatteryStatus );
       
   251 
       
   252     void powerStateChanged(QSystemDeviceInfo::PowerState);
       
   253     void currentProfileChanged(QSystemDeviceInfo::Profile);
       
   254     void bluetoothStateChanged(bool);
       
   255 
       
   256 private:
       
   257     int batteryLevelCache;
       
   258     QSystemDeviceInfo::PowerState currentPowerStateCache;
       
   259     QSystemDeviceInfo::BatteryStatus batteryStatusCache;
       
   260     static QSystemDeviceInfoPrivate *self;
       
   261     QBluetoothListenerThread *btThread;
       
   262 
       
   263 protected:
       
   264     void connectNotify(const char *signal);
       
   265     void disconnectNotify(const char *signal);
       
   266 
       
   267 };
       
   268 
       
   269 
       
   270 class QSystemScreenSaverPrivate : public QObject
       
   271 {
       
   272     Q_OBJECT
       
   273 
       
   274 public:
       
   275     QSystemScreenSaverPrivate(QObject *parent = 0);
       
   276     ~QSystemScreenSaverPrivate();
       
   277 
       
   278     bool screenSaverInhibited();
       
   279     bool setScreenSaverInhibit();
       
   280 
       
   281 private:
       
   282     QString screenPath;
       
   283     QString settingsPath;
       
   284     bool screenSaverSecure;
       
   285     bool isInhibited;
       
   286     QTimer *ssTimer;
       
   287 
       
   288 private Q_SLOTS:
       
   289     void activityTimeout();
       
   290 
       
   291 };
       
   292 
       
   293 class QRunLoopThread : public QThread
       
   294 {
       
   295     Q_OBJECT
       
   296 
       
   297 public:
       
   298     QRunLoopThread(QObject *parent = 0);
       
   299     ~QRunLoopThread();
       
   300     bool keepRunning;
       
   301     void stop();
       
   302 
       
   303 protected:
       
   304     void run();
       
   305 
       
   306 private:
       
   307     void startNetworkChangeLoop();
       
   308     QMutex mutex;
       
   309     SCDynamicStoreRef storeSession;// = NULL;
       
   310     CFRunLoopSourceRef runloopSource;
       
   311 
       
   312 private Q_SLOTS:
       
   313 };
       
   314 
       
   315 class QLangLoopThread : public QThread
       
   316 {
       
   317     Q_OBJECT
       
   318 
       
   319 public:
       
   320     QLangLoopThread(QObject *parent = 0);
       
   321     ~QLangLoopThread();
       
   322     bool keepRunning;
       
   323     void stop();
       
   324 
       
   325 protected:
       
   326     void run();
       
   327 
       
   328 private:
       
   329     QMutex mutex;
       
   330 private Q_SLOTS:
       
   331 };
       
   332 
       
   333 class QBluetoothListenerThread : public QThread
       
   334 {
       
   335     Q_OBJECT
       
   336 
       
   337 public:
       
   338     QBluetoothListenerThread(QObject *parent = 0);
       
   339     ~QBluetoothListenerThread();
       
   340     bool keepRunning;
       
   341 
       
   342 public Q_SLOTS:
       
   343     void emitBtPower(bool);
       
   344     void stop();
       
   345 
       
   346 Q_SIGNALS:
       
   347     void bluetoothPower(bool);
       
   348 
       
   349 protected:
       
   350     void run();
       
   351     IONotificationPortRef port;
       
   352     CFRunLoopRef rl;
       
   353     CFRunLoopSourceRef rls;
       
   354 
       
   355 private:
       
   356     QMutex mutex;
       
   357 
       
   358 private Q_SLOTS:
       
   359 };
       
   360 
       
   361 QTM_END_NAMESPACE
       
   362 
       
   363 QT_END_HEADER
       
   364 
       
   365 #endif /*QSYSTEMSINFO_MAC_P_H*/
       
   366 
       
   367 // End of file
       
   368