mpx/collectionframework/collectionserver/inc/mpxcollectionserversession.h
changeset 0 a2952bb97e68
equal deleted inserted replaced
-1:000000000000 0:a2952bb97e68
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Collection server session
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CMPXCOLLECTIONSESSION_H
       
    20 #define CMPXCOLLECTIONSESSION_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <e32cons.h>
       
    24 #include <f32file.h>
       
    25 #include <s32mem.h>
       
    26 #include <mpxcommand.h>
       
    27 #include "mpxcollectionengineobserver.h"
       
    28 #include "mpxcollectionserverdefs.h"
       
    29 
       
    30 class CMPXCollectionClientContext;
       
    31 class CMPXCollectionEngine;
       
    32 class CMPXMessageQueue;
       
    33 class CMPXMediaArray;
       
    34 class CMPXCollectionPath;
       
    35 
       
    36 /**
       
    37 * Music collection server session
       
    38 */
       
    39 class CMPXCollectionSession : public CSession2,
       
    40                               public MMPXCollectionEngineObserver
       
    41     {
       
    42 public:
       
    43 
       
    44     /**
       
    45     *  Two-phased constructor. Leaves on failure.
       
    46     *
       
    47     *  @param aEngine engine object
       
    48     *  @return The constructed object
       
    49     */
       
    50     static CMPXCollectionSession* NewL(CMPXCollectionEngine& aEngine);
       
    51 
       
    52     /**
       
    53     *  C++ constructor
       
    54     *
       
    55     *  @param aEngine engine object
       
    56     */
       
    57     CMPXCollectionSession(CMPXCollectionEngine& aEngine);
       
    58 
       
    59     /**
       
    60     *  Destructor
       
    61     */
       
    62     ~CMPXCollectionSession();
       
    63 
       
    64 private: // From base classes
       
    65 
       
    66     /**
       
    67     *  From MMPXCollectionEngineObserver
       
    68     *  Handles the collection entries/item being opened. Typically called
       
    69     *  when client has Open()'d a folder or an item
       
    70     *
       
    71     *  @param aMedia media to hold collection entries
       
    72     *  @param aIndex focused entry
       
    73     *  @param aComplete ETrue no more entries. EFalse more entries
       
    74     *                   expected
       
    75     *  @param aError error code
       
    76     */
       
    77     void HandleOpen(CMPXMedia* aMedia, TInt aIndex,
       
    78                     TBool aComplete,TInt aError);
       
    79 
       
    80     /**
       
    81     * From MMPXCollectionEngineObserver
       
    82     * Handles the completion of an async operation
       
    83     *
       
    84     * @param aError error code of completion
       
    85     */
       
    86     void HandleOpComplete(TInt aError);
       
    87 
       
    88     /**
       
    89     *  From MMPXCollectionEngineObserver
       
    90     *  Handle media properties
       
    91     *
       
    92     *  @param aMedia media
       
    93     *  @param aError error code
       
    94     */
       
    95     void HandleMedia(CMPXMedia* aMedia, TInt aError);
       
    96 
       
    97     /**
       
    98      *  From MMPXCollectionEngineObserver
       
    99      *  Handle completion of a asynchronous command
       
   100      *
       
   101      *  @param aCommandResult result of the command, NULL if error
       
   102      *  @param aError error code
       
   103      */
       
   104      void HandleCommandComplete(CMPXCommand* aCommandResult,
       
   105                                 TInt aError);
       
   106 
       
   107     /**
       
   108     *  From MMPXCollectionEngineObserver
       
   109     *  Handles remove by collection path
       
   110     *
       
   111     * @param aUriArray, contains a list of file paths to be deleted
       
   112     * @param aError error code
       
   113     */
       
   114     void HandleRemove(const CDesCArray& aUriArray, TInt aError);
       
   115 
       
   116     /**
       
   117     *  From MMPXCollectionEngineObserver
       
   118     *  Handles FindAllL results
       
   119     *
       
   120     *  @param aMedia media item(s)
       
   121     *  @param aError error code
       
   122     */
       
   123     void HandleFindAll(CMPXMedia* aMedia, TInt aError);
       
   124 
       
   125     /**
       
   126     *  From CSession2
       
   127     *  Service request
       
   128     *  @param aMessage message object
       
   129     */
       
   130     void ServiceL(const RMessage2& aMessage);
       
   131 
       
   132 private:
       
   133     /**
       
   134     *  Dispatch message
       
   135     *
       
   136     *  @param aMessage message object
       
   137     *  @return message completion code
       
   138     */
       
   139     TInt DispatchMessageL(const RMessage2& aMessage);
       
   140 
       
   141     /**
       
   142     *  Set collection mode
       
   143     *
       
   144     *  @param aMessage message object
       
   145     */
       
   146     void SetModeL(const RMessage2& aMessage);
       
   147 
       
   148     /**
       
   149     *  Set client id
       
   150     *
       
   151     *  @param aMessage message object
       
   152     */
       
   153     void SetClientIdL(const RMessage2& aMessage);
       
   154 
       
   155     /**
       
   156     *  Get client id from message
       
   157     *
       
   158     *  @param aMessage message object
       
   159     *  @reutrn client thread id
       
   160     */
       
   161     TThreadId ClientIdL(const RMessage2& aMessage);
       
   162 
       
   163     /**
       
   164     *  Init player from file
       
   165     *
       
   166     *  @param aMessage message object
       
   167     */
       
   168     void InitFromFileL(const RMessage2& aMessage);
       
   169 
       
   170     /**
       
   171     *  Cancel outstanding requests
       
   172     */
       
   173     void CancelRequests();
       
   174 
       
   175     /**
       
   176     *  Set request as async
       
   177     *
       
   178     *  @param aMessage message object
       
   179     */
       
   180     void SetAsyncL(const RMessage2& aMessage);
       
   181 
       
   182     /**
       
   183     *  Complete async request
       
   184     *
       
   185     *  @param aErr error code
       
   186     *  @param aSlot1 message slot 1
       
   187     *  @param aVal1 value in the slot 1
       
   188     *  @param aSlot2 message slot 2
       
   189     *  @param aVal2 value in the slot 2
       
   190     */
       
   191     void CompleteAsync(TInt aErr,
       
   192                        TInt aSlot1 = 0, const TDesC8* aVal1 = NULL,
       
   193                        TInt aSlot2 = 0,const TDesC8* aVal2 = NULL,
       
   194                        TInt aSlot3 = 0,const TDesC8* aVal3 = NULL);
       
   195 
       
   196     /**
       
   197     *  Writes data from the specified source descriptor to the specified
       
   198     *  message slot
       
   199     *
       
   200     *  @param aSlot1 message slot 1
       
   201     *  @param aVal1 value in the slot 1
       
   202     *  @param aSlot2 message slot 2
       
   203     *  @param aVal2 value in the slot 2
       
   204     *  @return KErrNone, if successful, otherwise system error code
       
   205     */
       
   206     TInt DoWriteData(TInt aSlot1 = 0, const TDesC8* aVal1 = NULL,
       
   207                      TInt aSlot2 = 0, const TDesC8* aVal2 = NULL,
       
   208                      TInt aSlot3 = 0, const TDesC8* aVal3 = NULL);
       
   209 
       
   210     /**
       
   211     *  Get current selection
       
   212     *
       
   213     *  @param aMessage message object
       
   214     */
       
   215     void GetSelectionL(const RMessage2& aMessage);
       
   216 
       
   217 private:
       
   218 
       
   219     /**
       
   220     *  2nd phase constructor
       
   221     */
       
   222     void ConstructL();
       
   223 
       
   224 private:
       
   225     CMPXCollectionEngine& iEngine;
       
   226     CMPXCollectionClientContext* iContext; // Not owned
       
   227 
       
   228     RMessage2 iMessage;
       
   229     TBool iCompleteRequest;
       
   230 
       
   231     //
       
   232     // Data for client, for current request
       
   233     //
       
   234     CBufBase* iAsyncBuffer; // buffer for async request
       
   235     CBufBase* iSyncBuffer; // buffer for sync request
       
   236     CMPXMedia* iSyncMedia; // Keep reference to result media of sync request
       
   237     CMPXMedia* iAsyncMedia; // Keep reference to result media of async request
       
   238     CMPXMessageQueue* iMessageQueue; // Message queue
       
   239     CMPXMediaArray* iRootMediaArray; // media array for media request of multi selection at root
       
   240     CMPXCommand* iMediaCommand; // a copy of media request command
       
   241     CMPXCollectionPath* iMediaPath; // path for media request
       
   242     };
       
   243 
       
   244 #endif // CMPXCOLLECTIONSESSION_H
       
   245