×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    3

    need help in detecting offline mode.

    I'm trying to implement some code that will, detect if the phone is in Offline Profile, then it will prompt the user some message telling him that he is in Offline Mode.

    But i've tried a lot of methods and look through a lot of guides, what I searched is only some guide that will display my device's profile.

    Below is the codes for the webview application i made. All i want is to detect the offline mode and display a message, then proceed to my html view. I've implemented the GetDeviceInfo.h file i get from some guide.
    But yeah, it doesnt work
    #include <QtGui>
    #include <QtWebKit>
    #include "qwebviewselectionsuppressor.h"
    #include <QSystemDeviceInfo>
    #include <QMessageBox>
    #include "GetDeviceInfo.h"

    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);
    QSystemDeviceInfo* deviceInfo = new QSystemDeviceInfo();
    QSystemDeviceInfo::Profile prof = deviceInfo->currentProfile();
    if(prof == QSystemDeviceInfo::OfflineProfile){
    QMessageBox msgBox;
    msgBox.setText("Your device is currently in Offline Mode, please switch it to Normal Mode in order to proceed.");
    msgBox.exec();
    }
    QWebView view;
    QWebViewSelectionSuppressor suppressor(&view);
    view.setWindowTitle("World Cup App");
    view.load(QUrl("qrc:/html/widget.html"));
    view.show();

    return app.exec();
    }

    Here's the original code of this page before i implement the codes:
    #include <QtGui>
    #include <QtWebKit>
    #include "qwebviewselectionsuppressor.h"

    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);
    QWebView view;
    QWebViewSelectionSuppressor suppressor(&view);
    view.setWindowTitle("World Cup App");
    view.load(QUrl("qrc:/html/widget.html"));
    view.show();

    return app.exec();
    }
    Can someone please teach me how to do it in a simple way? Thanks a lot for helping.

  2. #2
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: need help in detecting offline mode.

    You can use libprofile and profile_get_profile() to get the current profile.
    http://maemo.org/api_refs/5.0/5.0-fi...14ee2c569417b9

  3. #3
    Registered User
    Join Date
    Jan 2010
    Posts
    272

    Re: need help in detecting offline mode.

    Quote Originally Posted by divanov View Post
    You can use libprofile and profile_get_profile() to get the current profile.
    http://maemo.org/api_refs/5.0/5.0-fi...14ee2c569417b9
    I need a way to detect offline mode too. Could you please provide a code sample how to do this?

    Cheers

  4. #4
    Registered User
    Join Date
    Jan 2010
    Posts
    272

    Re: need help in detecting offline mode.

    Quote Originally Posted by Sasler View Post
    I need a way to detect offline mode too. Could you please provide a code sample how to do this?

    Cheers
    Oh, and one more thing. I would also need a way to make the "Exit Offline" dialog appear.

    Thank you very much in advance

  5. #5
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: need help in detecting offline mode.

    I've checked Qt Mobility and I cannot reproduce any kind of issues. I'm able to identify all profiles correctly
    Code:
    #include <QtGui>
    #include <QSystemDeviceInfo>
    #include <QSystemNetworkInfo>
    using namespace QtMobility;
    
    int main(int argc, char *argv[])
    {
        QCoreApplication app(argc, argv);
    
        QSystemDeviceInfo* deviceInfo = new QSystemDeviceInfo();
        QSystemDeviceInfo::Profile profile = deviceInfo->currentProfile();
        switch(profile) {
        case QSystemDeviceInfo::UnknownProfile:
            qDebug() << "Unknown";
            break;
        case QSystemDeviceInfo::SilentProfile:
            qDebug() << "Silent";
            break;
        case QSystemDeviceInfo::NormalProfile:
            qDebug() << "Normal";
            break;
        case QSystemDeviceInfo::LoudProfile:
            qDebug() << "Loud";
            break;
        case QSystemDeviceInfo::VibProfile:
            qDebug() << "Vib";
            break;
        case QSystemDeviceInfo::OfflineProfile:
            qDebug() << "Offline";
            break;
        case QSystemDeviceInfo::PowersaveProfile:
            qDebug() << "Powersave";
            break;
        case QSystemDeviceInfo::CustomProfile:
            qDebug() << "Custom";
            break;
        }
    }
    Are you sure you are not asking about network connection information?
    http://doc.qt.nokia.com/qtmobility-1...tworkinfo.html

  6. #6
    Registered User
    Join Date
    Jan 2010
    Posts
    272

    Re: need help in detecting offline mode.

    Quote Originally Posted by divanov View Post
    I've checked Qt Mobility and I cannot reproduce any kind of issues. I'm able to identify all profiles correctly
    Code:
    #include <QtGui>
    #include <QSystemDeviceInfo>
    #include <QSystemNetworkInfo>
    using namespace QtMobility;
    
    int main(int argc, char *argv[])
    {
        QCoreApplication app(argc, argv);
    
        QSystemDeviceInfo* deviceInfo = new QSystemDeviceInfo();
        QSystemDeviceInfo::Profile profile = deviceInfo->currentProfile();
        switch(profile) {
        case QSystemDeviceInfo::UnknownProfile:
            qDebug() << "Unknown";
            break;
        case QSystemDeviceInfo::SilentProfile:
            qDebug() << "Silent";
            break;
        case QSystemDeviceInfo::NormalProfile:
            qDebug() << "Normal";
            break;
        case QSystemDeviceInfo::LoudProfile:
            qDebug() << "Loud";
            break;
        case QSystemDeviceInfo::VibProfile:
            qDebug() << "Vib";
            break;
        case QSystemDeviceInfo::OfflineProfile:
            qDebug() << "Offline";
            break;
        case QSystemDeviceInfo::PowersaveProfile:
            qDebug() << "Powersave";
            break;
        case QSystemDeviceInfo::CustomProfile:
            qDebug() << "Custom";
            break;
        }
    }
    Are you sure you are not asking about network connection information?
    http://doc.qt.nokia.com/qtmobility-1...tworkinfo.html
    Thank you very much for this code. However, I need something that works with Qt 4.6.3 and, if I'm not completely mistaken, Qt Mobility is not included with it. Is there a way to do it in 4.6.3?

    Thanks

  7. #7
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: need help in detecting offline mode.

    Quote Originally Posted by Sasler View Post
    However, I need something that works with Qt 4.6.3 and, if I'm not completely mistaken, Qt Mobility is not included with it. Is there a way to do it in 4.6.3?
    Qt Mobility will be merged in Qt in 4.7. For now it's a set of separate libraries, however, it doesn't change anything for a developer.

  8. #8
    Registered User
    Join Date
    Jan 2010
    Posts
    272

    Re: need help in detecting offline mode.

    Quote Originally Posted by divanov View Post
    Qt Mobility will be merged in Qt in 4.7. For now it's a set of separate libraries, however, it doesn't change anything for a developer.
    Oh, so does it mean that I can use Qt Mobility already now and it will work in all N900 with PR1.2? It's not beta or anything?


    Thanks

  9. #9
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: need help in detecting offline mode.

    Quote Originally Posted by Sasler View Post
    Oh, so does it mean that I can use Qt Mobility already now and it will work in all N900 with PR1.2? It's not beta or anything?


    Thanks
    Mobility has reached 1.0.0 and 1.0.1 is almost done... but the latter has not been tagged yet.

  10. #10
    Registered User
    Join Date
    Jan 2010
    Posts
    272

    Re: need help in detecting offline mode.

    Quote Originally Posted by gnuton View Post
    Mobility has reached 1.0.0 and 1.0.1 is almost done... but the latter has not been tagged yet.
    Oh cool.

    Anyway, I'm trying to use this:

    Code:
       QSystemDeviceInfo* deviceInfo = new QSystemDeviceInfo();
            QSystemDeviceInfo::Profile profile = deviceInfo->currentProfile();
            if (profile == QSystemDeviceInfo::OfflineProfile) {
                updated = "The device is in Offline mode. Please exit Offline mode and try again.";
            } else {
                updated = "Connecting...";
            }
    But I get the following error in Qt Creator:

    undefined reference to 'QtMobility::QSystemDeviceInfo(QObject*)'
    undefined reference to 'QtMobility::QSystemDeviceInfo::currentProfile()'
    Am I doing something wrong?

    Cheers

  11. #11
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: need help in detecting offline mode.

    Quote Originally Posted by Sasler View Post
    Am I doing something wrong?
    Did you add
    Code:
    CONFIG += mobility
    MOBILITY += systeminfo
    to a project file? Did you install libqtm-dev?

  12. #12
    Registered User
    Join Date
    Jan 2010
    Posts
    272

    Re: need help in detecting offline mode.

    Quote Originally Posted by divanov View Post
    Did you add
    Code:
    CONFIG += mobility
    MOBILITY += systeminfo
    to a project file? Did you install libqtm-dev?
    Ehr... nope, sorry.

    But does the usage of libqtm-dev mean that it's not usable for public apps for N900?

  13. #13
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: need help in detecting offline mode.

    Quote Originally Posted by Sasler View Post
    Ehr... nope, sorry.

    But does the usage of libqtm-dev mean that it's not usable for public apps for N900?
    No. dev packages contain the header development files and tools.

  14. #14
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: need help in detecting offline mode.

    I don't know what is public application and what could be opposite to that (private application?), but there is no problem with using libqtm-dev.

  15. #15
    Registered User
    Join Date
    Jan 2010
    Posts
    272

    Re: need help in detecting offline mode.

    Quote Originally Posted by divanov View Post
    I don't know what is public application and what could be opposite to that, but there is no problem with using libqtm-dev.
    OK, let me rephrase my question. Can I use the it for an app that would be released in Extras or Ovi Store? If yes, do I need to add something to Debian control file, so that it will be able to install the necessary libs?

    Thank you very much for your help

Similar Threads

  1. Checking mobile offline mode
    By ahmadi2c in forum Mobile Java General
    Replies: 5
    Last Post: 2010-02-22, 11:16
  2. Replies: 1
    Last Post: 2009-08-06, 11:12
  3. Offline mode.
    By naimidrees in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2008-07-23, 08:58
  4. Offline mode and demo mode
    By teura666 in forum General Development Questions
    Replies: 1
    Last Post: 2006-01-12, 19:59
  5. N-Gage's offline mode
    By klinna in forum Symbian
    Replies: 0
    Last Post: 2003-11-11, 19:32

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×