securitydialogs/Autolock/src/main.cpp
changeset 63 989397f9511c
parent 26 aad866c37519
equal deleted inserted replaced
62:3255e7d5bd67 63:989397f9511c
    22 // #include "xqservicelog.h"
    22 // #include "xqservicelog.h"
    23 #include <QDebug>
    23 #include <QDebug>
    24 
    24 
    25 #include <QApplication>
    25 #include <QApplication>
    26 #include "Autolock.h"
    26 #include "Autolock.h"
       
    27 #include "../PubSub/securityuisprivatepskeys.h"
    27 
    28 
    28 #include <hbapplication.h>
    29 #include <hbapplication.h>
    29 #include <hbmainwindow.h>
    30 #include <hbmainwindow.h>
       
    31 #include <apgwgnam.h>
       
    32 #include <eikenv.h>
    30 
    33 
    31 int main(int argc, char **argv)
    34 int main(int argc, char **argv)
    32 {
    35 {
    33     // qInstallMsgHandler(XQSERVICEMESSAGEHANDLER);
    36     // qInstallMsgHandler(XQSERVICEMESSAGEHANDLER);
    34     // XQSERVICE_DEBUG_PRINT(" ================== xxxx Autolock::main");
    37     // XQSERVICE_DEBUG_PRINT(" ================== xxxx Autolock::main");
    35     qDebug() << "================== xxxx QApplication Autolock::main";
    38     qDebug() << "================== xxxx QApplication Autolock::main";
       
    39     
       
    40     
       
    41     // Need to check whether process is already running. This happens if it's started from Stater, and 
       
    42     // before fully initialized, it's started by API through QtHighway
       
    43     TSecurityPolicy readPolicy(ECapabilityReadDeviceData);
       
    44     TSecurityPolicy writePolicy(ECapabilityWriteDeviceData);
       
    45     int ret = RProperty::Define(KPSUidSecurityUIs,
       
    46             KSecurityUIsLockInitiatorUID, RProperty::EInt, TSecurityPolicy(TSecurityPolicy::EAlwaysPass),
       
    47             writePolicy);
       
    48 		qDebug() << "KSecurityUIsLockInitiatorUID ret=" << ret;
       
    49     int myInitiatorUID = 0;
       
    50     int err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsLockInitiatorUID, myInitiatorUID);
       
    51 		qDebug() << "KSecurityUIsLockInitiatorUID err=" << err;
       
    52 		qDebug() << "KSecurityUIsLockInitiatorUID myInitiatorUID=" << myInitiatorUID;
       
    53 		err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsLockInitiatorUID, 0);
       
    54 
       
    55     // it takes about 3 seconds to start it, on device
    36     QApplication a( argc, argv );
    56     QApplication a( argc, argv );
       
    57     // hide server from TaskSwitcher
       
    58     CEikonEnv * env = CEikonEnv::Static();
       
    59     if(env) {
       
    60         env->RootWin().SetOrdinalPosition(0, ECoeWinPriorityNeverAtFront);
       
    61 
       
    62         CApaWindowGroupName *wgName = CApaWindowGroupName::NewLC(env->WsSession());    
       
    63         wgName->SetHidden(ETrue); // hides us from FSW and protects us from OOM FW etc.
       
    64         wgName->SetSystem(ETrue); // Allow only application with PowerManagement cap to shut us down    
       
    65         // wgName->SetCaptionL(KRunningAppServerName);
       
    66         wgName->SetWindowGroupName(env->RootWin());
       
    67         CleanupStack::PopAndDestroy(wgName);
       
    68     }
       
    69 
    37     Autolock *cl = new Autolock();
    70     Autolock *cl = new Autolock();
    38     // qDebug() << " ================== xxxx cl->show";
    71     // qDebug() << " Autolock::main cl->show";
    39     // cl->show();
    72     // cl->show();
    40     // qDebug() << " ================== xxxx cl->hide";
    73     // qDebug() << " Autolock::main cl->hide";
    41     cl->hide();
    74     cl->hide();
    42     // qDebug() << " ================== xxxx cl->lower";
    75     // qDebug() << " Autolock::main cl->lower";
    43     cl->lower();
    76     cl->lower();
       
    77     qDebug() << " Autolock::main cl->lower";
       
    78     err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsLockInitiatorUID, 1);
    44     int rv = a.exec();
    79     int rv = a.exec();
       
    80     qDebug() << " Autolock::main cl->exec";
    45     delete cl;
    81     delete cl;
       
    82     qDebug() << " Autolock::main cl->delete";
    46     return rv;
    83     return rv;
    47 }
    84 }
    48 
    85