×
Namespaces

Variants
Actions
(Difference between revisions)

Working with QSystemNetworkInfo - System Information API - Part 2

From Nokia Developer Wiki
Jump to: navigation, search
avisheksomani (Talk | contribs)
(Source file)
hamishwillee (Talk | contribs)
m (Text replace - "<code cpp>" to "<code cpp-qt>")
 
(12 intermediate revisions by 5 users not shown)
Line 1: Line 1:
[[Category:Qt]][[Category:Qt for Symbian]][[Category:Qt Mobility]][[Category:Code Examples]]
+
{{ArticleMetaData <!-- v1.2 -->
 +
|sourcecode= [[Media:SystemNetworkInfo2.zip]]  
 +
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 +
|devices= <!-- Devices tested against - e.g. ''devices=Nokia 6131 NFC, Nokia C7-00'') -->
 +
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Qt SDK 1.1.4]) -->
 +
|platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later -->
 +
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 +
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 +
|signing= <!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
 +
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 +
|keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase -->
 +
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 +
|translated-by= <!-- [[User:XXXX]] -->
 +
|translated-from-title= <!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|review-by= <!-- After re-review: [[User:username]] -->
 +
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 +
|update-by= <!-- After significant update: [[User:username]]-->
 +
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 +
|creationdate= 20100315
 +
|author= [[User:Kiran10182]]
 +
}}
 +
[[Category:Qt Mobility]]
 
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"  
 
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"  
 
|-
 
|-
Line 9: Line 31:
 
|'''Tested on devices''' || Nokia 5800 xPressMusic
 
|'''Tested on devices''' || Nokia 5800 xPressMusic
 
|-
 
|-
|'''Category''' || Qt for Symbian
+
|'''Category''' || Qt
 
|'''Subcategory''' || Qt Mobility API
 
|'''Subcategory''' || Qt Mobility API
 
|-
 
|-
Line 23: Line 45:
  
 
{{Tip|<b></b>
 
{{Tip|<b></b>
* Please read this article before moving forward: [[Setting up environment for Qt Mobility API]]
+
* Please read this article before moving forward: [[Archived:Setting up environment for Qt Mobility API]]
 
* Setup Carbide.c++ IDE as explained in this article: [[Working with Carbide.c++ IDE for Qt Mobility APIs]]
 
* Setup Carbide.c++ IDE as explained in this article: [[Working with Carbide.c++ IDE for Qt Mobility APIs]]
 
}}
 
}}
  
  
= Overview ==
 
This is a part 2 of the '''''QSystemNetworkInfo API''''' which is a part of the '''''System Information API''''' from '''''Qt Mobility project'''''.
 
  
= What is covered in QSystemNetworkInfo API Part 2 =
+
==  Overview ==
 +
 +
{{Abstract|This is a part 2 of the {{Icode|QSystemNetworkInfo}} API which is a part of the '''''System Information API''''' from '''''Qt Mobility project'''''. The part 1 of this article can be read from [[Working with QSystemNetworkInfo - System Information API - Part 1|Here]] }}
 +
 
 +
= What is covered in {{Icode|QSystemNetworkInfo}} API Part 2 =
 
* It is a part of the System Information API.
 
* It is a part of the System Information API.
 
* This article covers information about
 
* This article covers information about
** MAC address of the specified network mode
+
* MAC address of the specified network mode
** Network status of the specified network mode
+
* Network status of the specified network mode
  
  
  
= Capabilities required =
+
=Capabilities required ==
* ReadDeviceData
+
 +
* '''ReadDeviceData'''
  
  
= UI design (.ui file) =
 
[[File:QSystemNetworkInfo-2_UI.PNG]]
 
  
 +
==  UI design (.ui file) ==
 +
 +
[[File:QSystemNetworkInfo-2 UI.PNG]]
  
  
= Project configuration file (.Pro file) =
+
 
* Add the Qt Mobility project configuration option in the .Pro file as shown below
+
 
<code cpp>
+
== Project configuration file (.Pro file) ==
 +
 +
* Add the Qt Mobility project configuration option in the '''.pro''' file as shown below
 +
<code cpp-qt>
 
CONFIG += mobility
 
CONFIG += mobility
 
MOBILITY += systeminfo
 
MOBILITY += systeminfo
Line 56: Line 85:
  
  
* Add required capability in .pro file as shown below:
+
* Add required capability in '''.pro''' file as shown below:
<code cpp>
+
<code cpp-qt>
 
symbian:TARGET.CAPABILITY = ReadDeviceData
 
symbian:TARGET.CAPABILITY = ReadDeviceData
 
</code>
 
</code>
  
  
= Implementing QSystemNetworkInfo API =
+
 
* QSystemNetworkInfo API is a part of the QtMobility namespace. So declare the QtMobility namespace as shown below:
+
== Implementing QSystemNetworkInfo API ==
<code cpp>
+
 +
* {{Icode|QSystemNetworkInfo}} API is a part of the {{Icode|QtMobility}} namespace. So declare the {{Icode|QtMobility}} namespace as shown below:
 +
<code cpp-qt>
 
using namespace QtMobility;
 
using namespace QtMobility;
 
</code>
 
</code>
  
 
== Header file==
 
== Header file==
<code cpp>
+
<code cpp-qt>
 
#ifndef SYSTEMNETWORKINFO2_H
 
#ifndef SYSTEMNETWORKINFO2_H
 
#define SYSTEMNETWORKINFO2_H
 
#define SYSTEMNETWORKINFO2_H
Line 103: Line 134:
  
 
== Source file ==
 
== Source file ==
<code cpp>
+
<code cpp-qt>
 
#include "SystemNetworkInfo2.h"
 
#include "SystemNetworkInfo2.h"
  
Line 156: Line 187:
 
{
 
{
 
return "Undefined";
 
return "Undefined";
                          break;
 
 
}
 
}
 
case QSystemNetworkInfo::NoNetworkAvailable:
 
case QSystemNetworkInfo::NoNetworkAvailable:
 
{
 
{
 
return "Unavailable";
 
return "Unavailable";
break;
 
 
}
 
}
 
case QSystemNetworkInfo::EmergencyOnly:
 
case QSystemNetworkInfo::EmergencyOnly:
 
{
 
{
 
return "Emergency";
 
return "Emergency";
break;
 
 
}
 
}
 
case QSystemNetworkInfo::Searching:
 
case QSystemNetworkInfo::Searching:
 
{
 
{
 
return "Searching";
 
return "Searching";
break;
 
 
}
 
}
 
case QSystemNetworkInfo::Busy:
 
case QSystemNetworkInfo::Busy:
 
{
 
{
 
return "Busy";
 
return "Busy";
break;
 
 
}
 
}
 
case QSystemNetworkInfo::Connected:
 
case QSystemNetworkInfo::Connected:
 
{
 
{
 
return "Connected";
 
return "Connected";
break;
 
 
}
 
}
 
case QSystemNetworkInfo::HomeNetwork:
 
case QSystemNetworkInfo::HomeNetwork:
 
{
 
{
 
return "On home n/w";
 
return "On home n/w";
break;
 
 
}
 
}
 
case QSystemNetworkInfo::Denied:
 
case QSystemNetworkInfo::Denied:
 
{
 
{
 
return "Access denied";
 
return "Access denied";
break;
 
 
}
 
}
 
case QSystemNetworkInfo::Roaming:
 
case QSystemNetworkInfo::Roaming:
 
{
 
{
 
return "On Roaming";
 
return "On Roaming";
break;
 
 
}
 
}
 
default:
 
default:
 
{
 
{
 
return "Error";
 
return "Error";
break;
 
 
}
 
}
 
}
 
}
Line 214: Line 235:
 
</code>
 
</code>
  
= Output =
 
[[File:QSystemNetworkInfo-2_device.jpg]]
 
  
  
= Useful functions =
+
==  Output ==
* QString macAddress(QSystemNetworkInfo::NetworkMode mode);
+
* QSystemNetworkInfo::NetworkStatus networkStatus(QSystemNetworkInfo::NetworkMode mode);
+
[[File:QSystemNetworkInfo-2 device.jpg]]
 +
 
 +
 
 +
== Useful functions ==
 +
 +
* {{Icode|QString macAddress(QSystemNetworkInfo::NetworkMode mode);}}
 +
* {{Icode|QSystemNetworkInfo::NetworkStatus networkStatus(QSystemNetworkInfo::NetworkMode mode);}}
  
  
Line 226: Line 251:
  
 
==Headers==
 
==Headers==
* #include <qsysteminfo.h>
+
<code cpp-qt>#include <qsysteminfo.h></code>
  
 
==Classes==
 
==Classes==
* QSystemNetworkInfo
+
* {{Icode|QSystemNetworkInfo}}
* QString
+
*{{Icode| QString}}
* QButton
+
*{{Icode| QButton}}
* QLabel
+
*{{Icode| QLabel}}
* QComboBox
+
*{{Icode| QComboBox}}
  
  
= Example Application =
+
 
 +
== Example Application ==
 +
 
* A working example application is available to download from here: [[Media:SystemNetworkInfo2.zip|QSystemNetworkInfo part2.zip]]
 
* A working example application is available to download from here: [[Media:SystemNetworkInfo2.zip|QSystemNetworkInfo part2.zip]]
  
Line 242: Line 269:
 
= Related articles =  
 
= Related articles =  
 
* [[Getting started with Qt Mobility APIs]]
 
* [[Getting started with Qt Mobility APIs]]
* [[Setting up environment for Qt Mobility API]]
+
* [[Archived:Setting up environment for Qt Mobility API]]
 
* [[Working with Carbide.c++ IDE for Qt Mobility APIs]]
 
* [[Working with Carbide.c++ IDE for Qt Mobility APIs]]
 
* [[Working with QSystemInfo - System Information API - Part 1]]
 
* [[Working with QSystemInfo - System Information API - Part 1]]
Line 254: Line 281:
 
* [http://qt.nokia.com/ Qt - cross-platform application and UI framework]
 
* [http://qt.nokia.com/ Qt - cross-platform application and UI framework]
 
* [http://labs.trolltech.com/page/Projects/QtMobility Qt Mobility API]
 
* [http://labs.trolltech.com/page/Projects/QtMobility Qt Mobility API]
* [http://qt.nokia.com/developer/new-qt-apis New Qt APIs Beta - Mobility Project]
+
* [http://qt.nokia.com/developer/qt-roadmap New Qt APIs Beta - Mobility Project]
* SDK help
+
* SDK help[[Category:Code Examples]][[Category:MeeGo Harmattan]] [[Category:Symbian]]

Latest revision as of 04:23, 11 October 2012

Article Metadata
Code ExampleCompatibility
Platform(s):
Symbian
Article
Created: kiran10182 (15 Mar 2010)
Last edited: hamishwillee (11 Oct 2012)
ID Creation date 15-March-2010
Platform S60 3rd Edition, FP1, FP2

S60 5th Edition

Tested on devices Nokia 5800 xPressMusic
Category Qt Subcategory Qt Mobility API


Keywords (APIs, classes, methods, functions): QSystemNetworkInfo, QString, QButton, QLabel, QComboBox


Tip.pngTip: 


Contents

[edit] Overview

This is a part 2 of the QSystemNetworkInfo API which is a part of the System Information API from Qt Mobility project. The part 1 of this article can be read from Here

[edit] What is covered in QSystemNetworkInfo API Part 2

  • It is a part of the System Information API.
  • This article covers information about
  • MAC address of the specified network mode
  • Network status of the specified network mode


[edit] Capabilities required

  • ReadDeviceData


[edit] UI design (.ui file)

QSystemNetworkInfo-2 UI.PNG



[edit] Project configuration file (.Pro file)

  • Add the Qt Mobility project configuration option in the .pro file as shown below
CONFIG += mobility
MOBILITY += systeminfo


  • Add required capability in .pro file as shown below:
symbian:TARGET.CAPABILITY = ReadDeviceData


[edit] Implementing QSystemNetworkInfo API

  • QSystemNetworkInfo API is a part of the QtMobility namespace. So declare the QtMobility namespace as shown below:
using namespace QtMobility;

[edit] Header file

#ifndef SYSTEMNETWORKINFO2_H
#define SYSTEMNETWORKINFO2_H
 
#include <QtGui/QWidget>
#include "ui_SystemNetworkInfo2.h"
#include <qsysteminfo.h>
 
using namespace QtMobility;
class SystemNetworkInfo2 : public QWidget
{
Q_OBJECT
 
public:
SystemNetworkInfo2(QWidget *parent = 0);
~SystemNetworkInfo2();
 
public slots:
void displayNetworkInfo(int aIndex);
void resetAllFields();
 
private:
QString getNetworkStatusString(QSystemNetworkInfo::NetworkStatus aIndex);
 
private:
Ui::SystemNetworkInfo2 ui;
QSystemNetworkInfo* networkInfo;
};
 
#endif // SYSTEMNETWORKINFO2_H


[edit] Source file

#include "SystemNetworkInfo2.h"
 
SystemNetworkInfo2::SystemNetworkInfo2(QWidget *parent)
: QWidget(parent), networkInfo(NULL)
{
ui.setupUi(this);
networkInfo = new QSystemNetworkInfo();
QObject::connect(ui.comboBox,
SIGNAL(currentIndexChanged(int)),
this,
SLOT(displayNetworkInfo(int)));
QObject::connect(ui.resetButton,
SIGNAL(clicked()),
this,
SLOT(resetAllFields()));
}
 
SystemNetworkInfo2::~SystemNetworkInfo2()
{
delete networkInfo;
networkInfo = NULL;
}
 
void SystemNetworkInfo2::displayNetworkInfo(int aIndex)
{
if(! aIndex)
{
resetAllFields();
return;
}
 
QString macAddress = networkInfo->macAddress((QSystemNetworkInfo::NetworkMode)aIndex);
if(! macAddress.length())
{
ui.macLabel->setText("Not applicable");
}
else
{
ui.macLabel->setText(macAddress);
}
ui.statusLabel->setText(getNetworkStatusString(
networkInfo->networkStatus(
(QSystemNetworkInfo::NetworkMode)aIndex)));
}
 
QString SystemNetworkInfo2::getNetworkStatusString(QSystemNetworkInfo::NetworkStatus aIndex)
{
switch(aIndex)
{
case QSystemNetworkInfo::UndefinedStatus:
{
return "Undefined";
}
case QSystemNetworkInfo::NoNetworkAvailable:
{
return "Unavailable";
}
case QSystemNetworkInfo::EmergencyOnly:
{
return "Emergency";
}
case QSystemNetworkInfo::Searching:
{
return "Searching";
}
case QSystemNetworkInfo::Busy:
{
return "Busy";
}
case QSystemNetworkInfo::Connected:
{
return "Connected";
}
case QSystemNetworkInfo::HomeNetwork:
{
return "On home n/w";
}
case QSystemNetworkInfo::Denied:
{
return "Access denied";
}
case QSystemNetworkInfo::Roaming:
{
return "On Roaming";
}
default:
{
return "Error";
}
}
}
 
void SystemNetworkInfo2::resetAllFields()
{
ui.macLabel->clear();
ui.statusLabel->clear();
ui.comboBox->setCurrentIndex(0);
}


[edit] Output

QSystemNetworkInfo-2 device.jpg


[edit] Useful functions

  • QString macAddress(QSystemNetworkInfo::NetworkMode mode);
  • QSystemNetworkInfo::NetworkStatus networkStatus(QSystemNetworkInfo::NetworkMode mode);


[edit] Keywords

[edit] Headers

#include <qsysteminfo.h>

[edit] Classes

  • QSystemNetworkInfo
  • QString
  • QButton
  • QLabel
  • QComboBox


[edit] Example Application


[edit] Related articles

[edit] Reference links

This page was last modified on 11 October 2012, at 04:23.
59 page views in the last 30 days.