mds_plat/harvester_framework_api/inc/harvesterdata.h
changeset 58 fe894bb075c2
parent 51 87e65c44ff3a
child 60 79f826a55db2
equal deleted inserted replaced
51:87e65c44ff3a 58:fe894bb075c2
     1 /*
       
     2 * Copyright (c) 2006-2009 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:  Data transfer object for harvest data
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef HARVESTERDATA_H
       
    20 #define HARVESTERDATA_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32std.h>
       
    24 #include <e32base.h>
       
    25 #include <badesca.h>
       
    26 #include <mdccommon.h>
       
    27 #include <locationdatatype.h>
       
    28 
       
    29 #include <harvesterclientdata.h>
       
    30 #include <placeholderdata.h>
       
    31 
       
    32 #include "mdeconstants.h"
       
    33 
       
    34 // FORWARD DECLARATIONS
       
    35 class CContextEngine;
       
    36 class CHarvesterBlacklist;
       
    37 class CMdEObject;
       
    38 class CHarvesterPluginInfo;
       
    39 class CHarvesterData;
       
    40 
       
    41 // ENUMERATIONS
       
    42 enum THarvesterEventType
       
    43 	{
       
    44 	EHarvesterAdd,      // New item to harvest
       
    45 	EHarvesterEdit,     // Re-harvest existing item
       
    46 	EHarvesterDelete,   // Delete item
       
    47 	EHarvesterUnknown   // Unknown command
       
    48 	};
       
    49 
       
    50 enum THarvesterObjectType
       
    51 	{
       
    52 	ENormal,           // Normal harvesting
       
    53 	EPlaceholder,      // Placeholder harvesting
       
    54 	EFastHarvest       // Fast harvesting - Harvester client request
       
    55 	};
       
    56 
       
    57 /**
       
    58  * Observer interface for notifications of harvesting completion from Harvesting
       
    59  * plug-ins to Harvester server side
       
    60  */
       
    61 class MHarvesterPluginObserver
       
    62 	{
       
    63     public:
       
    64     	/**
       
    65 	    * Called when harvesting of a file/item is completed
       
    66 	    *
       
    67 	    * @param aHarvesterData  Pointer to harvesting related data/harvesting request data
       
    68 	    */
       
    69     	virtual void HarvestingCompleted( CHarvesterData* aHarvesterData ) = 0;
       
    70 	};
       
    71 
       
    72 /**
       
    73  * Observer interface for adding new harvesting requests to Harvester server queue from
       
    74  * Monitor plug-ins
       
    75  */
       
    76 class MMonitorPluginObserver
       
    77 	{
       
    78     public:
       
    79     	/**
       
    80     	 * Method which is called by the monitor plug-in when event is monitored/
       
    81     	 * new harvesting request inserted to Harvester server queue.
       
    82     	 *
       
    83     	 * @param aHarvesterData  harvester data type
       
    84     	 */
       
    85     	virtual void MonitorEvent( CHarvesterData* aHarvesterData ) = 0;
       
    86     	
       
    87     	/**
       
    88     	 * Method which is called by the monitor plug-in when event is monitored/
       
    89     	 * new harvesting request inserted to Harvester server queue.
       
    90     	 * 
       
    91     	 * @param aHarvesterDataArray  Pointer to an array of harvesting related 
       
    92     	 *                             data/harvesting request data
       
    93     	 */
       
    94     	virtual void MonitorEvent( RPointerArray<CHarvesterData>& aHarvesterDataArray ) = 0;
       
    95 	};
       
    96 
       
    97 /**
       
    98  *  Class that encapsulates harvesting related data/harvesting request data. These instances
       
    99  *  are moved around the MdS Harvesting framework and this class encapsulates all information
       
   100  *  needed when harvesting a file/item.
       
   101  * 
       
   102  */
       
   103 NONSHARABLE_CLASS( CHarvesterData ) : public CBase
       
   104 	{
       
   105     public:
       
   106     
       
   107     	/**
       
   108     	 * Destructor.
       
   109     	 */
       
   110     	~CHarvesterData();
       
   111     
       
   112     	/**
       
   113     	 * Two-phased constructor.
       
   114     	 * 
       
   115     	 * @param aUri  URI of the file, usually filename. With messages can be messageID.
       
   116     	 */
       
   117     	IMPORT_C static CHarvesterData* NewL(const HBufC* aUri);
       
   118     	
       
   119     	/**
       
   120     	 * Two-phased constructor.
       
   121     	 *
       
   122     	 * @param aUri  URI of the file, usually filename. With messages can be messageID.
       
   123     	 */
       
   124     	IMPORT_C static CHarvesterData* NewLC(const HBufC* aUri);
       
   125     
       
   126     	/**
       
   127     	 * Method returns the URI.
       
   128     	 *
       
   129     	 * @return  URI.
       
   130     	 */
       
   131     	IMPORT_C const TDesC& Uri();
       
   132   
       
   133     	/**
       
   134     	 * Method returns error code of harvesting.
       
   135     	 *
       
   136     	 * @return  harvesting error code.
       
   137     	 */    	  
       
   138     	IMPORT_C TInt ErrorCode();
       
   139 
       
   140     	/**
       
   141     	 * Method sets the error code for harvesting.
       
   142     	 * 
       
   143     	 * @param aErrorCode  Error code for harvesting 
       
   144     	 */    	    	
       
   145     	IMPORT_C void SetErrorCode(TInt aErrorCode);
       
   146 
       
   147     	/**
       
   148     	 * Method sets harvesting type.
       
   149     	 * 
       
   150     	 * @param aEventType  Harvesting type
       
   151     	 */    	    
       
   152     	IMPORT_C void SetEventType(THarvesterEventType aEventType);
       
   153 
       
   154     	/**
       
   155     	 * Method returns harvesting type.
       
   156     	 * 
       
   157     	 * @return  Harvesting type
       
   158     	 */ 
       
   159       	IMPORT_C THarvesterEventType EventType();
       
   160 
       
   161     	/**
       
   162     	 * Method sets observer for this harvesting request (Harvester server)
       
   163     	 * 
       
   164     	 * @param aObserver  Pointer to the harvesting observer in the harvesting FW
       
   165     	 */     	
       
   166     	IMPORT_C void SetPluginObserver(MHarvesterPluginObserver& aObserver);
       
   167 
       
   168     	/**
       
   169     	 * Method returns pointer to the harvesting observer (Harvester server).
       
   170     	 * 
       
   171     	 * @return  Pointer to harvesting observer
       
   172     	 */     
       
   173     	IMPORT_C MHarvesterPluginObserver* PluginObserver();
       
   174     	
       
   175     	/**
       
   176     	 * Method sets the origin information for the file/item.
       
   177     	 * 
       
   178     	 * @param aOrigin  Origin of the file/item.
       
   179     	 */     	
       
   180     	IMPORT_C void SetOrigin(TOrigin aOrigin);
       
   181 
       
   182     	/**
       
   183     	 * Method returns origin of the file/item.
       
   184     	 * 
       
   185     	 * @return  Origin of the file/item.
       
   186     	 */ 
       
   187       	IMPORT_C TOrigin Origin();
       
   188 
       
   189     	/**
       
   190     	 * Method sets flag whether Context snapshot (with Context Engine)
       
   191     	 * is required during harvesting.
       
   192     	 * 
       
   193     	 * @param aTakeSnapshot  Whether Context snapshot is required or not.
       
   194     	 */       	    	
       
   195     	IMPORT_C void SetTakeSnapshot(TBool aTakeSnapshot);
       
   196 
       
   197     	/**
       
   198     	 * Method returns whether Context snapshot is required or not.
       
   199     	 * 
       
   200     	 * @return  Whether Context snapshot is required or not.
       
   201     	 */     	
       
   202     	IMPORT_C TBool TakeSnapshot();
       
   203   
       
   204     	/**
       
   205     	 * Method sets (object) type of the harvesting procedure.
       
   206     	 * 
       
   207     	 * @param aObjectType  Type of the harvesting procedure. 
       
   208     	 */     	  	
       
   209     	IMPORT_C void SetObjectType(THarvesterObjectType aObjectType);
       
   210     	
       
   211     	/**
       
   212          * Method retursn the (object) type of the harvesting procedure.
       
   213          *
       
   214          * @return  Type of the harvesting procedure.
       
   215     	 */     	
       
   216     	IMPORT_C THarvesterObjectType ObjectType();
       
   217     
       
   218     	/**
       
   219     	 * Method sets the custom harvesting data from client.
       
   220     	 * 
       
   221     	 * @param aClientData  Custom harvesting data from client.
       
   222     	 */     	
       
   223     	IMPORT_C void SetClientData(CBase* aClientData);
       
   224     	
       
   225     	/**
       
   226          * Method returns the custom harvesting data (received from client)
       
   227          *
       
   228          * @return  Custom harvesting data (received from client)
       
   229     	 */     	
       
   230     	IMPORT_C CBase* ClientData();
       
   231     	
       
   232     	/**
       
   233     	 * Method sets metadata object which will be used to store the metadata
       
   234     	 * in the harvesting plug-in.
       
   235     	 * 
       
   236     	 * @param aMdeObject  Pointer to the metadata object that will be used 
       
   237     	 *                    to store the metadata from the file/item.
       
   238     	 */     	
       
   239     	IMPORT_C void SetMdeObject( CMdEObject* aMdeObject );
       
   240 
       
   241     	/**
       
   242          * Method returns the metadata objects which is used to store the metadata
       
   243          * from the file/item that is harvested.
       
   244          *
       
   245          * @return  Metadata object that is used to store the metadata.
       
   246     	 */     	    	
       
   247     	IMPORT_C CMdEObject& MdeObject();
       
   248 
       
   249     	/**
       
   250     	 * Method sets location metadadata (GPS).
       
   251     	 * 
       
   252     	 * @param aLD  Pointer to the location metadata structure.
       
   253     	 */     	    	
       
   254     	IMPORT_C void SetLocationData( TLocationData* aLD );
       
   255     	
       
   256     	/**
       
   257          * Method returns the location metadata structure.
       
   258          *
       
   259          * @return  Location metadata structure.
       
   260     	 */     	
       
   261     	IMPORT_C TLocationData* LocationData();
       
   262     
       
   263     	/**
       
   264     	 * Method sets the client application UID.
       
   265     	 * 
       
   266     	 * @param aClientId  Client application UID.
       
   267     	 */     	
       
   268         IMPORT_C void SetClientId(TUid aClientId);
       
   269     	
       
   270     	/**
       
   271          * Method returns the client application UID.
       
   272          *
       
   273          * @return  Client application UID.
       
   274     	 */         
       
   275         IMPORT_C TUid ClientId();
       
   276     	
       
   277     	/**
       
   278          * Method returns whether location data should be added to
       
   279          * MdE DB or not.
       
   280          *
       
   281          * @return  Flag which defines whether location data needs to 
       
   282          *          be added or not.
       
   283     	 */ 		
       
   284         IMPORT_C TBool AddLocation();
       
   285 		
       
   286     	/**
       
   287     	 * Method sets a flag which defines whether location data
       
   288     	 * should be added to MdE DB or not.
       
   289     	 * 
       
   290     	 * @param aAdd  Client application UID.
       
   291     	 */         
       
   292         IMPORT_C void SetAddLocation( TBool aAdd );
       
   293 		
       
   294     	/**
       
   295     	 * Method sets harvesting plug-in information which
       
   296     	 * is needed to carry out the harvesting procedure
       
   297     	 * 
       
   298     	 * @param aPluginInfo  Pointer to harvester plug-in info structure.
       
   299     	 */         
       
   300 		IMPORT_C void SetHarvesterPluginInfo( CHarvesterPluginInfo* aPluginInfo );
       
   301 		
       
   302     	/**
       
   303          * Method returns harvester plug-in info structure.
       
   304          *
       
   305          * @return  Harvester plug-in info structure.
       
   306     	 */ 		
       
   307 		IMPORT_C CHarvesterPluginInfo* HarvesterPluginInfo();
       
   308 		
       
   309     	/**
       
   310          * Method returns whether item in harvesting is a binary file.
       
   311          *
       
   312          * @return  Whether item in harvesting is a binary file.
       
   313     	 */ 		
       
   314 		IMPORT_C TBool IsBinary();
       
   315 
       
   316     	/**
       
   317     	 * Method sets a flag determinning 
       
   318     	 * 
       
   319     	 * @param aPluginInfo  Pointer to harvester plug-in info structure.
       
   320     	 */    		
       
   321 		IMPORT_C void SetBinary( TBool aValue );
       
   322 
       
   323     
       
   324     private:
       
   325     
       
   326     	/**
       
   327     	 * Constructor for performing 1st stage construction
       
   328     	 * 
       
   329     	 * @param aUri  URI of the item ie. filename.
       
   330     	 */
       
   331     	CHarvesterData(const HBufC* aUri);
       
   332     
       
   333     	/**
       
   334     	 * Default constructor for performing 2nd stage construction
       
   335     	 */
       
   336     	void ConstructL();
       
   337     
       
   338     	/* URI descriptor */
       
   339     	const HBufC* iUri;
       
   340     	
       
   341     	/* Harvesting error code */
       
   342     	TInt iErrorCode;
       
   343     	
       
   344     	/* Harvesting event type */
       
   345     	THarvesterEventType iEventType;
       
   346     	
       
   347     	/* Harvesting observer ie. Harvester server */
       
   348     	MHarvesterPluginObserver* iObserver;
       
   349     	
       
   350     	/* Origin of the file/item */
       
   351     	TOrigin iOrigin;
       
   352     	
       
   353     	/* Whether Context snapshot is needed */
       
   354     	TBool iTakeSnapshot;
       
   355     	
       
   356     	/* Object type for harvesting */
       
   357     	THarvesterObjectType iObjectType;
       
   358     	
       
   359     	/* Custom client data */
       
   360     	CBase* iClientData;
       
   361     	
       
   362     	/* Pointer to metadata object */
       
   363     	CMdEObject* iMdeObject;
       
   364     	
       
   365     	/* Harvesting plug-in info */
       
   366     	CHarvesterPluginInfo* iPluginInfo;
       
   367     	
       
   368     	/* GPS and other location related data */
       
   369     	TLocationData* iLocationData;
       
   370     	
       
   371     	/* Whether location data needs to be added to DB */
       
   372     	TBool iAddLocation;
       
   373     	
       
   374     	/* Whether item to harvest is a binary file */
       
   375     	TBool iIsBinary;
       
   376     	
       
   377     	/* Executable UID which created the binary file */
       
   378 		TUid iClientId;
       
   379 	};
       
   380 
       
   381 #endif // HARVESTERDATA_H
       
   382