contentstorage/cahandler/app/src/caapphandler.cpp
changeset 124 e36b2f4799c0
parent 121 0b3699f6c654
equal deleted inserted replaced
121:0b3699f6c654 124:e36b2f4799c0
    20 #include <w32std.h>
    20 #include <w32std.h>
    21 #include <apgtask.h>
    21 #include <apgtask.h>
    22 #include <apgcli.h>
    22 #include <apgcli.h>
    23 #include <eikenv.h>
    23 #include <eikenv.h>
    24 #include <eikappui.h>
    24 #include <eikappui.h>
    25 #include <vwsdef.h>
       
    26 #include <AknDef.h>
    25 #include <AknDef.h>
    27 #include <AknTaskList.h>
    26 #include <AknTaskList.h>
    28 
    27 
    29 #include <usif/usifcommon.h>
    28 #include <usif/usifcommon.h>
    30 #include <usif/scr/scr.h>
    29 #include <usif/scr/scr.h>
    45 
    44 
    46 static const char caTypeApp[] = "application";
    45 static const char caTypeApp[] = "application";
    47 static const char caTypePackage[] = "package";
    46 static const char caTypePackage[] = "package";
    48 static const char caTypeWidget[] = "widget";
    47 static const char caTypeWidget[] = "widget";
    49 static const char caAttrView[] = "view";
    48 static const char caAttrView[] = "view";
    50 static const char caCmdClose[] = "close";
       
    51 static const char caAttrWindowGroupId[] = "window_group_id";
       
    52 static const char caAttrComponentId[] = "component_id";
    49 static const char caAttrComponentId[] = "component_id";
    53 
    50 
    54 /*!
    51 /*!
    55  *  Command handler for application entries.
    52  *  Command handler for application entries.
    56  *
    53  *
   101         if (viewIdIsCorrect) {
    98         if (viewIdIsCorrect) {
   102             QString uidValue =
    99             QString uidValue =
   103                 entry.attribute(APPLICATION_UID_ATTRIBUTE_NAME);
   100                 entry.attribute(APPLICATION_UID_ATTRIBUTE_NAME);
   104             int uid = uidValue.toInt();
   101             int uid = uidValue.toInt();
   105             TRAP(result, launchApplicationL(TUid::Uid(uid), viewId));
   102             TRAP(result, launchApplicationL(TUid::Uid(uid), viewId));
   106         }
       
   107     } else if (command == caCmdClose && entry.entryTypeName() == caTypeApp ) {
       
   108         QString windowGroupId = entry.attribute(caAttrWindowGroupId);
       
   109         if (!windowGroupId.isNull()) {
       
   110             result = closeApplication(entry.flags(), windowGroupId.toInt());
       
   111         }
   103         }
   112     } else if (command == caCmdRemove) {
   104     } else if (command == caCmdRemove) {
   113         QString componentId(entry.attribute(caAttrComponentId));
   105         QString componentId(entry.attribute(caAttrComponentId));
   114         result = handleRemove(entry.flags(),
   106         result = handleRemove(entry.flags(),
   115             entry.entryTypeName(),
   107             entry.entryTypeName(),
   176         }
   168         }
   177         CleanupStack::PopAndDestroy( &wsSession );
   169         CleanupStack::PopAndDestroy( &wsSession );
   178     }
   170     }
   179 }
   171 }
   180 
   172 
   181 /*!
       
   182  * Closes application.
       
   183  * \param flags an entry flags.
       
   184  * \param windowGroupId window group id.
       
   185  * \retval an error code.
       
   186  */
       
   187 int CaAppHandler::closeApplication(const EntryFlags &flags, int windowGroupId)
       
   188 {
       
   189     int result(KErrNone);
       
   190     if (windowGroupId > 0) {
       
   191         RWsSession wsSession;
       
   192         result = wsSession.Connect();
       
   193         if (result==KErrNone) {
       
   194             TWsEvent event;
       
   195             event.SetTimeNow();
       
   196             event.SetType(KAknShutOrHideApp);
       
   197             wsSession.SendEventToWindowGroup(windowGroupId, event);
       
   198         }
       
   199         wsSession.Close();
       
   200     }
       
   201     return result;
       
   202 }
       
   203 
   173 
   204 /*!
   174 /*!
   205  * Uninstall application.
   175  * Uninstall application.
   206  * \param flags flags of the application which is to uninstall.
   176  * \param flags flags of the application which is to uninstall.
   207  * \param typeName type name of the entry.
   177  * \param typeName type name of the entry.