×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Jun 2012
    Posts
    43

    Changing Vibration of General and Offline profile

    Hello,

    I wrote a little tool which toggles the vibration of the active profile:

    Code:
    #include <mproengengine.h>
    #include <proengfactory.h>
    #include <mproengprofile.h>
    #include <MProEngToneSettings.h>
    #include <AknGlobalNote.h>
    
    LOCAL_C void ExeMainL()
    {
        MProEngEngine* iProfileEngine = ProEngFactory::NewEngineLC();
        MProEngProfile* activeProfile = iProfileEngine->ActiveProfileLC();
        MProEngToneSettings& ts = activeProfile->ToneSettings();
        TBool vibra = !ts.VibratingAlert();
        ts.SetVibratingAlert(vibra);
        TRAPD(error,
              activeProfile->CommitChangeL();
                );
        CAknGlobalNote* note = CAknGlobalNote::NewLC();
        TRequestStatus iStatus;
        if(vibra)
            note->ShowNoteL(iStatus, EAknGlobalConfirmationNote, _L("Done\nEnabled vibration."));
        else
            note->ShowNoteL(iStatus, EAknGlobalConfirmationNote, _L("Done\nDisabled vibration."));
        User::WaitForRequest(iStatus);
        CleanupStack::PopAndDestroy(3);
    }
    
    TInt E32Main()
    {
        CTrapCleanup* cl=CTrapCleanup::New();
        TRAPD(error, ExeMainL());
        delete cl;
        return error;
    }
    It works fine if the phone is in silent or Meeting, but if it's in General or Offline I get this:

    Code:
    A thread crashed: Thread 0x1e6a has panicked. Category: E32USER-CBase; Reason: 44
    I am using a Nokia 808 PureView on Belle FP2 and somebody else tested it on his N8 with the same result.
    The debugger shows it happens while calling
    Code:
    CommitChangeL();
    The project file:

    Code:
    SOURCES += main.cpp
    RESOURCES +=
    LIBS += -lprofileengine -laknnotify
    
    TARGET.CAPABILITY += WriteDeviceData
    
    CONFIG -= qt
    
    default_deployment.pkg_prerules -= pkg_depends_webkit
    default_deployment.pkg_prerules -= pkg_depends_qt
    
    
    INCLUDEPATH += C:/QtSDK/Symbian/SDKs/Symbian3Qt474/epoc32/include/
    INCLUDEPATH += C:/QtSDK/Symbian/SDKs/Symbian3Qt474/epoc32/include/platform/
    INCLUDEPATH += C:/QtSDK/Symbian/SDKs/Symbian3Qt474/epoc32/include/platform/mw/
    INCLUDEPATH += C:/QtSDK/Symbian/SDKs/Symbian3Qt474/epoc32/include/mw/
    INCLUDEPATH += C:/QtSDK/Symbian/SDKs/Symbian3Qt474/epoc32/include/bafl/
    INCLUDEPATH += C:/QtSDK/Symbian/SDKs/Symbian3Qt474/epoc32/include/app
    I am using Nokia Qt SDK 1.2.1 with Symbian Anna SDK and I tried multiple GCCE versions.

    The same problem happens with this example code:

    Code:
        MProEngEngine* engine = ProEngFactory::NewEngineLC();
        MProEngProfile* activeProfile = engine->ActiveProfileLC();
        MProEngToneSettings& ts = activeProfile->ToneSettings();
        ts.SetVibratingAlert( ETrue );
        activeProfile->CommitChangeL();
        CleanupStack::PopAndDestroy(2);
    from http://docs.huihoo.com/symbian/s60-3...pper_API4.html

    and even

    Code:
        MProEngEngine* engine = ProEngFactory::NewEngineLC();
        MProEngProfile* activeProfile = engine->ActiveProfileLC();
        activeProfile->CommitChangeL();
        CleanupStack::PopAndDestroy(2);
    Can you find the error?

    Thanks in advance
    Last edited by huellif; 2014-04-14 at 11:09.

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

    Re: Changing Vibration of General and Offline profile

    This panic is raised by the Start(), Stop() and Add() member functions of an active scheduler, a CActiveScheduler. It is caused by attempting to start or stop an active scheduler or by attempting to add an active object, a CActive, to the active scheduler. says the docs.

    And I'm not seeing you handling any active scheduler stuff in there

  3. #3
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: Changing Vibration of General and Offline profile

    While it is not obvious from the method calls, the profile engine likely uses active objects internally. Whenever you see M-things (interfaces), it often happens.
    As a first try instantiate and Install a CActiveScheduler object at the beginning of the method (ExeMainL). Then Install a null at the end, and delete the object. (CActiveScheduler::Install is a static method)

  4. #4
    Registered User
    Join Date
    Jun 2012
    Posts
    43

    Re: Changing Vibration of General and Offline profile

    Quote Originally Posted by symbianyucca View Post
    This panic is raised by the Start(), Stop() and Add() member functions of an active scheduler, a CActiveScheduler. It is caused by attempting to start or stop an active scheduler or by attempting to add an active object, a CActive, to the active scheduler. says the docs.

    And I'm not seeing you handling any active scheduler stuff in there
    Yes it's strange, I checked the error code tables and thought what to hell is going on, it makes no sense.

    Quote Originally Posted by wizard_hu_ View Post
    While it is not obvious from the method calls, the profile engine likely uses active objects internally. Whenever you see M-things (interfaces), it often happens.
    As a first try instantiate and Install a CActiveScheduler object at the beginning of the method (ExeMainL). Then Install a null at the end, and delete the object. (CActiveScheduler::Install is a static method)
    Thanks for the hint, now it's working fine

    Here's the working code:
    (I wouldn't say fixed code because it seems like the API/its documentation itself is the issue)

    Code:
    #include <mproengengine.h>
    #include <proengfactory.h>
    #include <mproengprofile.h>
    #include <MProEngToneSettings.h>
    #include <AknGlobalNote.h>
    
    LOCAL_C void ExeMainL()
    {
        CActiveScheduler* scheduler = new CActiveScheduler;
        CActiveScheduler::Install(scheduler);
        MProEngEngine* iProfileEngine = ProEngFactory::NewEngineLC();
        MProEngProfile* activeProfile = iProfileEngine->ActiveProfileLC();
        MProEngToneSettings& ts = activeProfile->ToneSettings();
        TBool vibra = !ts.VibratingAlert();
        ts.SetVibratingAlert(vibra);
        TRAPD(error,
              activeProfile->CommitChangeL();
                );
        CAknGlobalNote* note = CAknGlobalNote::NewLC();
        TRequestStatus iStatus;
        if(vibra)
            note->ShowNoteL(iStatus, EAknGlobalConfirmationNote, _L("Done\nEnabled vibration."));
        else
            note->ShowNoteL(iStatus, EAknGlobalConfirmationNote, _L("Done\nDisabled vibration."));
        User::WaitForRequest(iStatus);
        CleanupStack::PopAndDestroy(3);
        delete scheduler;
    }
    
    TInt E32Main()
    {
        CTrapCleanup* cl=CTrapCleanup::New();
        TRAPD(error, ExeMainL());
        delete cl;
        return error;
    }
    Last edited by huellif; 2014-04-14 at 18:46.

Similar Threads

  1. Replies: 1
    Last Post: 2010-04-22, 03:42
  2. Vibration Profile Setting on 3rd Ed
    By dangeross in forum Symbian
    Replies: 7
    Last Post: 2009-12-17, 10:51
  3. N78 reboots when I switch of offline profile while using nokia maps
    By suvarnas in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2009-08-12, 12:39
  4. Changing ringtones by changing profile programatically
    By daredevilWin in forum Symbian Media (Closed)
    Replies: 0
    Last Post: 2005-05-24, 07:59
  5. change vibration of profile
    By hemanstani in forum Symbian
    Replies: 0
    Last Post: 2003-10-29, 19:21

Posting Permissions

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