• May 02, 2024, 05:08:18 am

Author Topic: Simple firmware version check  (Read 2477 times)

0 Members and 1 Guest are viewing this topic.

Offline huellif

  • Developer
  • Christmas Santa
  • ****
  • Posts: 402
  • Reputation: 212
Simple firmware version check
« on: August 10, 2014, 05:39:22 pm »
Symbian stores the firmware version as a number in Z:/resource/versions/sw.txt

Reading :/resource/ doesn't need any capabilties and there are many ways to do it, e.g. via HAL API, native C++ file APIs, QtMobilty and others.
But all of them need imports, linking against a .dll etc., but in the end it comes down to reading the file.

So you can use QFile and a few lines of code to do that, e.g. if you want heavy features on FP2 only and not on Refresh:

Code: [Select]
bool isFP2() const
{
     QFile verFile("Z:/resource/versions/sw.txt");
     if(!verFile.open(QFile::ReadOnly | QFile::Text))
          return false;
     return QTextStream(&verFile).readLine().split(".").at(0).toInt(0) == 113;
}

(Closing QFile isn't required, it happens automatically in the destructor)

If you want the main number of the firmware version itself:

Code: [Select]
int getFirmwareVersion() const
{
     QFile verFile("Z:/resource/versions/sw.txt");
     if(!verFile.open(QFile::ReadOnly | QFile::Text))
          return -1;
     return QTextStream(&verFile).readLine().split(".").at(0).toInt(0);
}

You just have to import this two headers:

Code: [Select]
#include <QFile>
#include <QTextStream>

Both are part of the QCore module, so it even works in console apps :)

Regards
« Last Edit: August 10, 2014, 05:44:50 pm by huellif »