qtinternetradio/ui/src/irsymbianapplication.cpp
changeset 3 ee64f059b8e1
parent 2 2e1adbfc62af
child 4 3f2d53f144fe
child 5 0930554dc389
equal deleted inserted replaced
2:2e1adbfc62af 3:ee64f059b8e1
     1 /*
       
     2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 #include <coemain.h>
       
    19 #include <apgwgnam.h>
       
    20 
       
    21 #include "irsymbianapplication.h"
       
    22 #include "irsymbiandocument.h"
       
    23 
       
    24 IRSymbianApplication * IRSymbianApplication::appInstance = NULL;
       
    25 
       
    26 CApaApplication *newS60Application()
       
    27 {
       
    28     return IRSymbianApplication::getInstance();
       
    29 }
       
    30 
       
    31 IRSymbianApplication * IRSymbianApplication::getInstance()
       
    32 {
       
    33     if (NULL == appInstance)
       
    34     {
       
    35         appInstance = new IRSymbianApplication;
       
    36     }
       
    37     
       
    38     return appInstance;
       
    39 }
       
    40 
       
    41 bool IRSymbianApplication::getInstanceFlag() const
       
    42 {
       
    43     return iSecondInstance;
       
    44 }
       
    45 
       
    46 IRSymbianApplication::IRSymbianApplication() : iSecondInstance(false)
       
    47 {
       
    48     
       
    49 }
       
    50 
       
    51 CApaDocument * IRSymbianApplication::CreateDocumentL()
       
    52 {
       
    53     return IRSymbianDocument::getInstance();
       
    54 }
       
    55 
       
    56 void IRSymbianApplication::PreDocConstructL()
       
    57 {
       
    58     RWsSession& ws = iCoeEnv->WsSession();
       
    59     const TInt myWgId = iCoeEnv->RootWin().Identifier();
       
    60     TInt wgId = 0;
       
    61     TUid uid(AppDllUid());
       
    62     iSecondInstance = false;
       
    63     
       
    64     // Look for another instance of this app
       
    65     while (wgId >= 0)
       
    66     {
       
    67         if (wgId && wgId != myWgId)
       
    68         {
       
    69             iSecondInstance = true;
       
    70         }
       
    71         CApaWindowGroupName::FindByAppUid(uid, ws, wgId);
       
    72     }
       
    73     
       
    74     if (!iSecondInstance)
       
    75     {
       
    76         CAknApplication::PreDocConstructL(); 
       
    77     }
       
    78 }
       
    79