Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 25

Hybrid View

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    15

    Question How to Enable Power Saving Mode

    Hello, I'm trying to enable "Power Saving Mode" in Qt, I found how to enable Power saving mode with Symbian^3 (Symbian C++ Code). So it tried to convert it to work in Qt C++ but I failed.

    Could someone convert it to work in Qt C++? or give me another solution.
    Last edited by Motaz New; 2013-04-10 at 13:20.

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,185

    Re: How to Enable Power Saving Mode

    Basically as far as I know there is no other ways, unless of course you find some internal C++ API which would do the stuff.

    anyway, the code snipped you have shown works with PS keys, thus should be fairly easy to get working. And thus you might want to explain on what you have tried, and what has happened..

  3. #3
    Registered User
    Join Date
    Aug 2009
    Posts
    15

    Re: How to Enable Power Saving Mode

    Thank you symbianyucca, Now I gave up

  4. #4
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,185

    Re: How to Enable Power Saving Mode

    Basically we are here to help, and we can not really do all things, basically if you would follow the advises given, and try out, then you would get it working just fine. anyway, if you don't want to do, its of course upto you.

  5. #5
    Registered User
    Join Date
    Aug 2009
    Posts
    15

    Post Re: How to Enable Power Saving Mode

    Thank you symbianyucca, this is my work (I beginner ):

    psmmode_p.h
    Code:
    #ifndef PSMMODE_P_H
    #define PSMMODE_P_H
    
    //headers from sf-Sources
    #include <psmclientobserver.h>
    #include <psmclient.h>
    #include <psmsettings.h>
    #include <psmmode.h>
    
    #ifdef BUILD_DLL
    #define DLL_EXPORT Q_DECL_EXPORT
    #else
    #define DLL_EXPORT Q_DECL_IMPORT
    #endif
    
    class DLL_EXPORT PSMModePrivate : public MPsmClientObserver
    {
    public:
        //static PSMModePrivate* NewL(PSMMode *aPublicAPI = 0);
        PSMModePrivate();
        ~PSMModePrivate();
    
    public:
        void runPSMMode();
        void exitPSMMode();
    
    private:
        CPsmClient *iPsmClient;
    };
    
    #endif // PSMMODE_P_H
    psmmode_p.cpp
    Code:
    #include "psmmode_p.h"
    #include "psmmode.h"
    
    PSMModePrivate::PSMModePrivate()
    {
        QT_TRAP_THROWING(iPsmClient = CPsmClient::NewL( *this ));
    }
    
    PSMModePrivate::~PSMModePrivate()
    {
        delete iPsmClient;
        iPsmClient = NULL;
    }
    
    void PSMModePrivate::runPSMMode()
    {
        iPsmClient->RequestPowerSaveModeNotification();
        iPsmClient->ChangePowerSaveMode(EPsmsrvModePowerSave);
    }
    
    void PSMModePrivate::exitPSMMode()
    {
        iPsmClient->RequestPowerSaveModeNotification();
        iPsmClient->ChangePowerSaveMode(EPsmsrvModeNormal);
    }

  6. #6
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,185

    Re: How to Enable Power Saving Mode

    And what is wrong with it ?

  7. #7
    Registered User
    Join Date
    Aug 2009
    Posts
    15

    Re: How to Enable Power Saving Mode

    Hi, I followed your advises symbianyucca but the program freezes when try to run the private constructor PSMModePrivate::PSMModePrivate(PSMMode *aPublicAPI)

    psmmode_p.cpp
    Code:
    #include "psmmode_p.h"
    #include "psmmode.h"
    
    PSMModePrivate* PSMModePrivate::NewL(PSMMode *aPublicAPI)
    {
        PSMModePrivate* self = new (ELeave) PSMModePrivate(aPublicAPI);
        // push onto cleanup stack in case self->ConstructL leaves
        CleanupStack::PushL(self);
        // complete construction with second phase constructor
        self->ConstructL();
        CleanupStack::Pop(self);
        return self;
    }
    
    void PSMModePrivate::ConstructL()
    {
        QT_TRAP_THROWING(iPsmClient = CPsmClient::NewL( *this ));
        emit iPsmClient->RequestPowerSaveModeNotification();
    }
    
    PSMModePrivate::PSMModePrivate(PSMMode *aPublicAPI)
     : d_ptr(aPublicAPI), CActive(CActive::EPriorityHigh)
    {
        CActiveScheduler::Add(this);
    //    QT_TRAP_THROWING(iPsmClient = CPsmClient::NewL( *this ));
    //    iPsmClient->RequestPowerSaveModeNotification();
    }
    
    PSMModePrivate::~PSMModePrivate()
    {
        Cancel();
        delete iPsmClient;
        //iPsmClient = NULL;
    }
    
    void PSMModePrivate::runPSMMode()
    {
        emit iPsmClient->RequestPowerSaveModeNotification();
        emit iPsmClient->ChangePowerSaveMode(EPsmsrvModePowerSave);
    }
    
    void PSMModePrivate::exitPSMMode()
    {
        emit iPsmClient->RequestPowerSaveModeNotification();
        emit iPsmClient->ChangePowerSaveMode(EPsmsrvModeNormal);
    }
    
    void PSMModePrivate::DoCancel()
    {
    
    }
    
    void PSMModePrivate::RunL()
    {
    
    }
    
    void PSMModePrivate::PowerSaveModeChangeError(const TInt aError)
    {
        if ( aError != KErrCancel ) // ignore error if it is due cancellation of notification request
        {
            if ( aError != KErrServerTerminated ) // new request would cause another completion with this error code (infinitely)
            {
                emit iPsmClient->RequestPowerSaveModeNotification(); // must be requested after every completion
            }
        }
    }
    
    void PSMModePrivate::PowerSaveModeChanged(const TPsmsrvMode aMode)
    {
        emit iPsmClient->RequestPowerSaveModeNotification(); // must be requested after every completion
    }

  8. #8
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,185

    Re: How to Enable Power Saving Mode

    PSMModePrivate::PSMModePrivate(PSMMode *aPublicAPI) doe not really do anything, thus I would not see how it could freeze, thus I would suppose it is other place where it does the freezing, basically it must be other line of code.

    Also is this Normal GUI application ? basically non UI apps might in some cases be missing active schedluer and cleanup stack etc. which are needed by this code.

  9. #9
    Registered User
    Join Date
    Aug 2009
    Posts
    15

    Re: How to Enable Power Saving Mode

    My program crash when run the code!!!

  10. #10
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,185

    Re: How to Enable Power Saving Mode

    so then you should try obtaining the panic code for the crash: http://www.developer.nokia.com/Commu...ded_panic_code it would likely help on determining what is going wrong in there. Also if you could find which line of code is causing the crash, it would also help.

  11. #11
    Registered User
    Join Date
    Aug 2009
    Posts
    15

    Re: How to Enable Power Saving Mode

    Also is this Normal GUI application ?
    It's normal Qt GUI application.

  12. #12
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,185

    Re: How to Enable Power Saving Mode

    Good, then it has Actice schedluer, & cleanup stack for symbian, so those should not be causing the problems. Then its back into the chase on where it actually hangs at.

    The line you earlier said hangs, is simply doing CActiveScheduler::Add(this); and that I have never ever seen hanging.

  13. #13
    Registered User
    Join Date
    Aug 2009
    Posts
    15

    Re: How to Enable Power Saving Mode

    You're right symbianyucca, The problem was due to a simple mistake in runPSMMode() and exitPSMMode() I used:
    iPsmClient->RequestPowerSaveModeNotification() instead of iPsmClient->CancelPowerSaveModeNotificationRequest()

    and the program work now.

    Thank you again symbianyucca for your help.

  14. #14
    Registered User
    Join Date
    Aug 2009
    Posts
    15

    Re: How to Enable Power Saving Mode

    I found the line where causing the crash

    Code:
    void PSMModePrivate::runPSMMode()
    {
    ->  iPsmClient->RequestPowerSaveModeNotification();
        iPsmClient->ChangePowerSaveMode(EPsmsrvModePowerSave);
    }
    and I get a message

    ---------------------------
    Signal received
    ---------------------------
    The inferior stopped because it received a signal from the Operating System.
    Signal name : SIGSEGV
    Signal meaning :Segmentation fault
    ---------------------------
    OK
    ---------------------------

  15. #15
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,185

    Re: How to Enable Power Saving Mode

    Firstly note that, you should not expect this to work in simulator or emulator environments. Secondly, please check the link given and get the actual panic code.

    if otehr ways fails, you could always try out the Y-Tasks:Crash monitor, the free self-signed version is enough for this use case.

Similar Threads

  1. Question about Power Saving Mode
    By ashraf fawzy in forum Symbian
    Replies: 6
    Last Post: 2011-11-18, 07:41
  2. SIP, WLAN and power saving
    By rkalff in forum Symbian
    Replies: 1
    Last Post: 2006-12-07, 15:02
  3. How to protect against power failure while saving data in RMS
    By rushabh_it in forum Mobile Java General
    Replies: 6
    Last Post: 2006-10-31, 03:57
  4. Hot to turn off power saving mode
    By desijatt in forum Mobile Java General
    Replies: 1
    Last Post: 2006-09-13, 08:31
  5. bluetooth power saving modes(park, sniff, etc. ) in series 60?
    By a4peace in forum Bluetooth Technology
    Replies: 3
    Last Post: 2004-11-30, 12:23

Posting Permissions

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