javaextensions/midppush/pushregistryplugin/inc/pushregistryhandler.h
branchRCL_3
changeset 19 04becd199f91
child 87 1627c337e51e
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2008 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:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef PUSHREGISTRYHANDLER_H
       
    20 #define PUSHREGISTRYHANDLER_H
       
    21 
       
    22 #include <memory>
       
    23 
       
    24 #include "javaosheaders.h"
       
    25 
       
    26 #include "comms.h"
       
    27 #include "extensionplugininterface.h"
       
    28 #include "applicationruntimeeventsinterface.h"
       
    29 #include "applicationmanagementeventsinterface.h"
       
    30 #include "eventconsumerinterface.h"
       
    31 #include "pushregistrymessages.h"
       
    32 #include "commslistener.h"
       
    33 #include "exceptionbase.h"
       
    34 #include "scopedlocks.h"
       
    35 #include "pushalarmutilsinterface.h"
       
    36 #include "driveutilities.h"
       
    37 #include "pushconncompletedtimercontainer.h"
       
    38 
       
    39 namespace java
       
    40 {
       
    41 
       
    42 namespace captain
       
    43 {
       
    44 class CoreInterface;
       
    45 }
       
    46 namespace comms
       
    47 {
       
    48 class CommsMessage;
       
    49 }
       
    50 namespace util
       
    51 {
       
    52 class Uid;
       
    53 }
       
    54 
       
    55 namespace push
       
    56 {
       
    57 
       
    58 class PushDataContainer;
       
    59 class PushAlarmHandler;
       
    60 class PushDBHandler;
       
    61 
       
    62 using java::captain::uids_t;
       
    63 
       
    64 /**
       
    65  * This class implements ExtensionPlugin interface of Java Manager.
       
    66  * I.e. this class is starting point for all push related tasks in the
       
    67  * Java Captain process.
       
    68  */
       
    69 OS_NONSHARABLE_CLASS(PushRegistryHandler) : public java::captain::ExtensionPluginInterface,
       
    70         public java::comms::CommsListener,
       
    71         public java::captain::ApplicationRuntimeEventsInterface,
       
    72         public java::captain::ApplicationManagementEventsInterface,
       
    73         public java::captain::EventConsumerInterface,
       
    74         public PushAlarmUtilsInterface,
       
    75         public PushConnCompletedTimerListener
       
    76 {
       
    77 public:
       
    78 
       
    79     OS_IMPORT PushRegistryHandler();
       
    80 
       
    81     OS_IMPORT virtual ~PushRegistryHandler();
       
    82 
       
    83     // PluginInterface
       
    84     virtual void startPlugin(java::captain::CoreInterface* aCore);
       
    85     virtual void stopPlugin();
       
    86 
       
    87     // ExtensionPluginInterface.
       
    88     virtual ApplicationRuntimeEventsInterface* getApplicationRuntimeListener();
       
    89     virtual ApplicationManagementEventsInterface* getApplicationManagementListener();
       
    90     virtual EventConsumerInterface* getEventConsumer();
       
    91 
       
    92 
       
    93     //Method of CommsListener.
       
    94     virtual void processMessage(java::comms::CommsMessage& aMessage);
       
    95 
       
    96     // ApplicationRuntimeEventsInterface
       
    97     virtual void arLaunched(const Uid& aUID, const int& aRuntimeCommsAddress);
       
    98     virtual void arTerminated(const Uid& aUID, const int& aExitCode);
       
    99 
       
   100     // ApplicationManagementEventsInterface
       
   101     virtual void amAdded(const uids_t& uids);
       
   102     virtual void amUpdated(const uids_t& uids);
       
   103     virtual void amDeleted(const uids_t& uids);
       
   104 
       
   105     // EventConsumerInterface
       
   106     virtual void event(const std::string& eventProvider,
       
   107                        java::comms::CommsMessage& aMsg);
       
   108 
       
   109     // PushConnCompletedTimerListener
       
   110     virtual void connCompletedTimerExpired(const java::comms::CommsMessage& aMsg);
       
   111 
       
   112 private:
       
   113 
       
   114     //Methods of PushAlarmUtilsInterface.
       
   115     virtual bool launchMidlet(const java::util::Uid& aMidletUid,
       
   116                               const int& aLaunchType);
       
   117     virtual int getMediaIdByMidletUid(const java::util::Uid& aMidletUid);
       
   118 
       
   119     //Datamembers.
       
   120     //This class does not take ownership of this datamember.
       
   121     java::captain::CoreInterface* mCore;
       
   122     std::auto_ptr<PushDBHandler> mPushDbHandler;
       
   123     std::auto_ptr<PushDataContainer> mPushDataContainer;
       
   124     std::auto_ptr<PushAlarmHandler> mPushAlarmHandler;
       
   125     //java::util::ScopedMutex mMutex;
       
   126     java::fileutils::driveInfos mDriveInfo;
       
   127     std::auto_ptr<PushConnCompletedTimerContainer> mConnCompletedTimerContainer;
       
   128 
       
   129     //Internal operations.
       
   130     void handleGetAllPushRegsMsg(java::comms::CommsMessage& aMsg);
       
   131     void getUris(std::wstring& aNumOfUriBuf,std::wstring& aUriBuf);
       
   132     void handleRegDynamicPushConnMsg(java::comms::CommsMessage& aMsg);
       
   133     void handleUnregDynamicPushConnMsg(java::comms::CommsMessage& aMsg);
       
   134     void handleRegisterAlarmMsg(java::comms::CommsMessage& aMsg);
       
   135     void handleAllConnsFailedMsg(java::comms::CommsMessage& aMsg);
       
   136     void handlePendingStatusMsg(java::comms::CommsMessage& aMsg);
       
   137     void handleListConnectionsMsg(java::comms::CommsMessage& aMsg);
       
   138     void handleDataOfPushConnQueryMsg(java::comms::CommsMessage& aMsg);
       
   139     void handlePushUriStartsWithQueryMsg(java::comms::CommsMessage& aMsg);
       
   140     void handleConnCompletedMsg(java::comms::CommsMessage& aMsg);
       
   141     void sendCommsResponseInSuccessCase(int aMsgId,const java::util::Uid& aUid,
       
   142                                         int aSenderOfOrigMsg,int aMsgRef);
       
   143     void sendRegisterAlarmReply(int aSenderOfOrigMsg,const java::util::Uid& aUid,
       
   144                                 const long long& aTimeInMilliSecs,int aMsgRef);
       
   145     void sendRegisterAlarmReplyInErrorCase(java::util::ExceptionBase& aEx,int aSenderOfOrigMsg,
       
   146                                            const java::util::Uid& aUid,int aMsgRef);
       
   147     void sendCommsResponseInErrorCase(java::util::ExceptionBase& aEx,int aMsgId,
       
   148                                       const java::util::Uid& aUid,
       
   149                                       int aSenderOfOrigMsg,int aMsgRef);
       
   150     void sendPushUriStartsWithQueryReplyInErrorCase(java::comms::CommsMessage& aMsg);
       
   151     void startPushMidlets();
       
   152     void deleteAppData(const java::util::Uid& aUid,const bool& aDeleteAlarm);
       
   153     void readAppData(const java::util::Uid& aUid,const bool& aUpdateAlarm);
       
   154     void manageDriveInsertion(const java::fileutils::driveInfo& aDriveInfo);
       
   155     void manageDriveRemoval(const java::fileutils::driveInfo& aDriveInfo);
       
   156     void startOrKillMidlet(const unsigned int aMediaId,bool aTerminateMidlet);
       
   157     void removeDriveFromContainer(const java::fileutils::driveInfo& aDriveInfo);
       
   158     bool isDriveAvailable(int aMediaId);
       
   159     void readUidArg(java::comms::CommsMessage& aMsg,const std::string& aMsgName,java::util::Uid& aUid);
       
   160     void readWStrArg(java::comms::CommsMessage& aMsg,const std::string& aMsgName,std::wstring& aUri);
       
   161     int readIntAsBooleanArg(java::comms::CommsMessage& aMsg,const std::string& aMsgName);
       
   162     int readIntArg(java::comms::CommsMessage& aMsg,const std::string& aMsgName);
       
   163     long long readLongLongArg(CommsMessage& aMsg,const std::string& aMsgName);
       
   164 
       
   165     //Not implemented.
       
   166     PushRegistryHandler(const PushRegistryHandler &x);
       
   167     PushRegistryHandler &operator=(const PushRegistryHandler &x);
       
   168 };
       
   169 
       
   170 }//end namespace push
       
   171 }//end namespace java
       
   172 
       
   173 #endif // PUSHREGISTRYHANDLER_H