internetradio2.0/irsessionlog/inc/irsessionlogger.h
changeset 14 896e9dbc5f19
child 15 065198191975
equal deleted inserted replaced
12:608f67c22514 14:896e9dbc5f19
       
     1 /*
       
     2 * Copyright (c) 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:  The implementation for presentation elements.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_IRSESSIONLOGGER_H
       
    20 #define C_IRSESSIONLOGGER_H
       
    21 
       
    22 #include <f32file.h>
       
    23 
       
    24 #include "irsessionparams.h"
       
    25 #include "mirphoneinfoobserver.h"
       
    26 
       
    27 class CIRSessionDb;
       
    28 class CIRSessionLogger;
       
    29 class CIRSettings;
       
    30 class CIRNmsLogDb;
       
    31 class CIRNmsLogger;
       
    32 class CPhoneInfo;
       
    33 class MIRLogDbStatusObserver;
       
    34 
       
    35 /**
       
    36  * This class is used to provide usage log, various function are to log session
       
    37  * information as well as others, like browse log information. Session logs can be 
       
    38  * stored in internel data base for last 5 session, it is deleted only if the 
       
    39  * response is given. If more than 5 session is happening at any point of time
       
    40  * first one based on session id is removed.
       
    41  * When you end a session a gzip file is generated in private path
       
    42  * This zip file has ( xml file ) session log in xml format
       
    43  * This is single ton implementation use DeleteInstance to delete its 
       
    44  * instance
       
    45  *
       
    46  * @lib irsessionlog.lib
       
    47  * @since S_60 3.0
       
    48  *
       
    49  */
       
    50 
       
    51 //============================ class declaration ========================
       
    52 
       
    53 NONSHARABLE_CLASS(CIRReportGenerator) : public CObject,
       
    54                                         public MIRPhoneInfoObserver
       
    55     {
       
    56     //member function
       
    57 public:
       
    58 
       
    59     /**
       
    60     * Function: NewL
       
    61     * Two phase constructor returns the instance of CIRReportGenerator
       
    62     * this is a single ton implementation
       
    63     * @note Deleting this object directly is not allowed. Please use Close().
       
    64     * @note CleanupClosePushL( generator ) must be used if the object is to be pushed onto cleanup stack.
       
    65     * @returns instance of CIRReportGenerator
       
    66     */    
       
    67     IMPORT_C static CIRReportGenerator* OpenL();
       
    68     
       
    69 private:    
       
    70     /**
       
    71     * Function: ~CIRReportGenerator
       
    72     * default destructor
       
    73     */    
       
    74     ~CIRReportGenerator();
       
    75     
       
    76     /**
       
    77     * Function: ConstructL
       
    78     * Two phase constructor
       
    79     */    
       
    80     void ConstructL();
       
    81     
       
    82     /**
       
    83     * Function: CIRReportGenerator
       
    84     * default constructor
       
    85     */    
       
    86     CIRReportGenerator();
       
    87 
       
    88 public:
       
    89 
       
    90     /**
       
    91     * Function: LogServerResult
       
    92     * logs server connection result
       
    93     * @param URL to which connection is attempted
       
    94     * @param response from server
       
    95     */        
       
    96     IMPORT_C void LogServerResult( const TDesC& aUrl, TResponse aResult );    
       
    97     
       
    98     /**
       
    99     * Function: LogSongRecog
       
   100     * logs song recog
       
   101     */  
       
   102     IMPORT_C void LogSongRecog();
       
   103     
       
   104     /**
       
   105     * Function: UpdateCurrentBrowseNetwork
       
   106     * logs network during browsing
       
   107     * @param mcc+ mnc code of current network
       
   108     */  
       
   109     IMPORT_C void UpdateCurrentBrowseNetwork(TInt aNetwork);
       
   110         
       
   111     /**
       
   112     * Function: LogBrowse
       
   113     * logs browse url and status information
       
   114     * @param browse url
       
   115     * @param status information
       
   116     */  
       
   117     IMPORT_C void LogBrowse(const TDesC8& aUrl,TInt aStatus);
       
   118             
       
   119     /**
       
   120     * Function: SessionStartedL
       
   121     * starts a new session
       
   122     */  
       
   123     IMPORT_C void SessionStartedL();
       
   124     /**
       
   125     * Function: NmsLogStartedL
       
   126     * starts a new nmslog
       
   127     */  
       
   128     IMPORT_C void NmsLogStartedL();
       
   129     /**
       
   130     * Function: SessionEnd
       
   131     * marks the a session
       
   132     */      
       
   133     IMPORT_C void SessionEndL();
       
   134     
       
   135     /**
       
   136     * Function: MarkSessionStart
       
   137     * marks the a start of a session
       
   138     */  
       
   139     IMPORT_C void MarkSessionStart();
       
   140     
       
   141     /**
       
   142     * Function: HandleStopEvents
       
   143     * function handle session state change events
       
   144     * @param ETrue if session is progressing and EFalse if not progressing
       
   145     */
       
   146     IMPORT_C void HandleStopEvents(TBool aIsSessionProgressing );
       
   147     
       
   148     /**
       
   149     * Function: UpdateTerminatedBy
       
   150     * updates the termination status
       
   151     * @param terminated by information
       
   152     */  
       
   153     IMPORT_C void UpdateTerminatedBy(TTerminationStatus aTerminatedBy);
       
   154     
       
   155     /**
       
   156     * Function: UpdateConnectedFrom
       
   157     * connected information is stored
       
   158     * @param connected from information
       
   159     */      
       
   160     IMPORT_C void UpdateConnectedFrom( TConnectedFrom aConnectedFrom );
       
   161     
       
   162     /**
       
   163     * Function: BrowseUrl
       
   164     * logs browse url and result
       
   165     * @param URL to which connection is attempted
       
   166     * @param response from server
       
   167     */    
       
   168     IMPORT_C void BrowseUrl( const TDesC& aBrowseUrl, TInt aStatus );
       
   169     
       
   170     /**
       
   171     * Function: UpdateChannelID
       
   172     * updates the channel id
       
   173     * @param channel id
       
   174     */    
       
   175     IMPORT_C void UpdateChannelID( TInt aChanneldID );
       
   176     
       
   177     /**
       
   178     * Function: UpdateCurrentNetwork
       
   179     * updates the current network
       
   180     * @param current network
       
   181     */    
       
   182     IMPORT_C void UpdateCurrentNetwork( TInt aCurrentNetwork );
       
   183     
       
   184     /**
       
   185     * Function: UpdateHomeOperator
       
   186     * updates the home network
       
   187     * @param home network
       
   188     */    
       
   189     IMPORT_C void UpdateHomeOperator( TInt aHomeOperator );
       
   190     
       
   191     /**
       
   192     * Function: UpdateConnectionType
       
   193     * updates the connection type
       
   194     * @param connection type
       
   195     */    
       
   196     IMPORT_C void UpdateConnectionType( const TDesC& aConnectionType );    
       
   197     
       
   198     /**
       
   199     * Function : ReponseFromISDSObtained
       
   200     * This function is called when session log is successfully sent
       
   201     * removes all session log entries from sessiondb
       
   202     */    
       
   203     IMPORT_C void ReponseFromISDSObtained();
       
   204     
       
   205     
       
   206     /**
       
   207      * The following methods are for Nms Event Usage Logging 
       
   208      */
       
   209     
       
   210     
       
   211     /**
       
   212      * Function: UpdateNmsCurrentNetwork
       
   213      * logs network during Music Store launching
       
   214      * @param mcc+ mnc code of current network
       
   215      */    
       
   216     IMPORT_C void UpdateNmsCurrentNetwork( TInt aNetwork );
       
   217     
       
   218     /**
       
   219      * Function: UpdateNmsHomeOperator
       
   220      * logs network during Music Store launching
       
   221      */    
       
   222     IMPORT_C void UpdateNmsHomeOperator( TInt aNetwork );
       
   223     
       
   224     /**
       
   225      * Function: WriteNmsLogtoXmlL
       
   226      * logs nmsEvents to Xml file
       
   227      */    
       
   228     IMPORT_C void WriteNmsLogtoXmlL();
       
   229     /**
       
   230     * Function: UpdateNmsType
       
   231     * updates the Nms type
       
   232     * @param Nms type
       
   233     */    
       
   234     IMPORT_C void UpdateNmsType( const TDesC& aNmsType );        
       
   235     /**
       
   236     * Function: UpdateNmsChannelID
       
   237     * updates the Nms channel id
       
   238     * @param Nms channel id
       
   239     */    
       
   240     IMPORT_C void UpdateNmsChannelID( TInt aChanneldID );
       
   241     /**
       
   242     * Function: SetDbStatusObserser
       
   243     * @param Db Status Observer
       
   244     */    
       
   245     IMPORT_C void SetDbStatusObserser( MIRLogDbStatusObserver *aDbStatusObserver );
       
   246     
       
   247     /**
       
   248     * Function: ReportSent();
       
   249     * notify that the usage report is just sent out to isds server
       
   250     */    
       
   251     IMPORT_C void ReportSent();    
       
   252 private:
       
   253 
       
   254     /**
       
   255     * Function: CollectSettingsData
       
   256     * collect information during starting of session
       
   257     * like irid, version information.
       
   258     */        
       
   259     void CollectSettingsData();
       
   260     
       
   261     /**
       
   262     * Function: WriteToXmlL
       
   263     * gathers the information and generates sesion log file and zip file
       
   264     * file will be stored in private path
       
   265     */    
       
   266     void WriteToXmlL();        
       
   267     
       
   268     /**
       
   269     * Function: WriteSessionData
       
   270     * gathers session log data and writes to XML file
       
   271     * @param no of urls tried to connect in that particular session
       
   272     */        
       
   273     void WriteSessionData(TInt aIndex);
       
   274     
       
   275     /**
       
   276     * Function: WriteBrowseLog
       
   277     * gathers browse log data and writes to XML file
       
   278     */    
       
   279     void WriteBrowseLog();
       
   280     
       
   281     /**
       
   282     * Function: ZipFileL
       
   283     * generates the zip file from the input xml file
       
   284     * output file is in gzip format and is stored in private path
       
   285     */    
       
   286     void ZipFileL();
       
   287     
       
   288     /**
       
   289     * Function: FormatDateTime
       
   290     * formats the date time given in "%d-%d-%d %d:%d:%d GMT\n" format
       
   291     * copies the result to a descriptor
       
   292     * @param reference of descriptor to which the data is to be copied
       
   293     * @param time to be copied
       
   294     */    
       
   295     void FormatDateTime( TDes& aBuffer, TDateTime aDateTime );
       
   296     
       
   297     /**
       
   298     * Function : WriteSessionLog
       
   299     * Write buffer content to log file
       
   300     */
       
   301     void WriteBufferToLogFile();
       
   302     
       
   303     /**
       
   304     * Function : UnForceSessionEndedL
       
   305     * Write session log
       
   306     * @param instance of session which ended
       
   307     */
       
   308     void UnForceSessionEndedL( CIRSessionLogger* aSession );
       
   309 
       
   310     /**
       
   311      * The following methods are for Nms Event Usage Logging 
       
   312      */
       
   313     
       
   314     /**
       
   315     * Function: WriteNmsLogData
       
   316     * gathers Nmslog data and writes to XML file
       
   317     * @param position of the log in the log data array
       
   318     */      
       
   319     void WriteNmsLogData( TInt aIndex );
       
   320     
       
   321     /**
       
   322      * From MIRPhoneInfoObserver
       
   323      */
       
   324     void ImeiUpdatedL( const TDesC& aImei );
       
   325     
       
   326 private:
       
   327     /**
       
   328     * opsetting instance 
       
   329     */
       
   330     CIRSettings* iSettingsData;
       
   331     
       
   332     /**
       
   333     * Phone Info 
       
   334     */  
       
   335     CPhoneInfo* iPhoneInfo;
       
   336     
       
   337     /**
       
   338     * instance of session logger
       
   339     */
       
   340     CIRSessionLogger* iSessionLog;
       
   341     /**
       
   342     * instance of nms logger
       
   343     */
       
   344     CIRNmsLogger* iNmsLog;
       
   345     
       
   346     /**
       
   347     * instance of sessiondb
       
   348     */ 
       
   349     CIRSessionDb* iLogSessionDb;
       
   350     /**
       
   351     * instance of NmsLogdb
       
   352     */ 
       
   353     CIRNmsLogDb* iNmsLogDb;
       
   354     /**
       
   355     * instance of Db Status Observer
       
   356     */
       
   357     MIRLogDbStatusObserver *iDbStatusObserver;
       
   358     /**
       
   359     * Indicate whether Nms Log Db has been updated
       
   360     */
       
   361     TBool iNmsLogDbUpdated;
       
   362     /**
       
   363     * Indicate whether Session Log Db has been updated
       
   364     */
       
   365     TBool iSessionLogDbUpdated;
       
   366     /**
       
   367     * Indicate whether usage report sent to isds server has received successful response
       
   368     */
       
   369     TBool iUnComfirmedReportSent;
       
   370     /**
       
   371     * it holds the sessions
       
   372     */
       
   373     CArrayPtrFlat<CIRSessionLogger> *iSessionData;
       
   374     /**
       
   375     * it holds the NmsLog
       
   376     */
       
   377     CArrayPtrFlat<CIRNmsLogger> *iNmsLogData;
       
   378     
       
   379     /**
       
   380     * position in xml file
       
   381     */
       
   382     TInt iFileWritePos;
       
   383 
       
   384     /**
       
   385     * stores the network during browsing
       
   386     */
       
   387     TInt iCurrentBrowseNetwork;
       
   388     
       
   389     /**
       
   390     * Checks whether any error has occured while 
       
   391     * writing or retriving from data base
       
   392     */
       
   393     TBool iSessionLogUpdationFailed;
       
   394     /**
       
   395     * Checks whether any error has occured while 
       
   396     * writing or retriving from data base
       
   397     */
       
   398     TBool iNmsLogUpdationFailed;
       
   399     
       
   400     /**
       
   401     * Checks whether db creation is failure or success
       
   402     */
       
   403     TBool iSessionDbCreationFailed;
       
   404     /**
       
   405     * Checks whether db creation is failure or success
       
   406     */
       
   407     TBool iNmsDbCreationFailed;
       
   408     /*
       
   409     * sets when an nms event is generated
       
   410     */
       
   411     TBool iNmsEventFlag;
       
   412     /**
       
   413     * log file
       
   414     */
       
   415     RFile iLogFile;
       
   416     
       
   417     /*
       
   418     * file session
       
   419     */
       
   420     RFs iFsSession;
       
   421     
       
   422     /**
       
   423     * unicode buffer
       
   424     */ 
       
   425     //"MAX_URL_CHARACTOR_NUMBER = 255" is defined 
       
   426     // in iropenwebaddressview.cpp, it is 8bit len char.
       
   427     // the memory should be double when tranfer 8bit to 16bit.  
       
   428     TBuf<512> iUniCodeBuf;  //Unicode
       
   429     
       
   430     /**
       
   431     * utf 8 buffer
       
   432     */
       
   433     TBuf8<256> iUTF8Buffer; //UTF-8
       
   434     
       
   435     /**
       
   436     * version number
       
   437     */
       
   438     TBuf<5> iReportVersion;
       
   439     
       
   440     /**
       
   441     * irid
       
   442     */
       
   443     TBuf<30>  iIRId;
       
   444     
       
   445     /**
       
   446     * Base64 encoded IMEI
       
   447     */
       
   448     HBufC *iImeiBase64;
       
   449     
       
   450     /**
       
   451     * session database file
       
   452     */
       
   453     TFileName iSessFile;
       
   454     /**
       
   455     * session database file
       
   456     */
       
   457     TFileName iNmsLogFile;
       
   458     
       
   459     /**
       
   460     * log files path
       
   461     */
       
   462     TFileName iLogFilePath;
       
   463     
       
   464     /**
       
   465     * instance of browse log    
       
   466     */
       
   467     TIRBrowseLog iRBrowseLog;
       
   468     
       
   469     /**
       
   470     * session start time
       
   471     */
       
   472     TTime iSessionStartTime;
       
   473     
       
   474     /**
       
   475      * Timestamp
       
   476     */
       
   477     TTime iSongRecogTimestamp;  
       
   478     
       
   479     /**
       
   480     * time stamp
       
   481     */
       
   482     TTime iBrowseLogTimeStamp;
       
   483     
       
   484     /**
       
   485     * date
       
   486     */
       
   487     TDateTime iDate;
       
   488     
       
   489     /**
       
   490     * array for storing browse log
       
   491     */    
       
   492     RArray<TIRBrowseLog> iBrowseLog;
       
   493     
       
   494     /**
       
   495     * number of browse logs written to xml
       
   496     */
       
   497     TInt iBrowseLogsCntToXml;
       
   498 
       
   499     
       
   500     /**
       
   501      * The following methods are for Nms Event Usage Logging 
       
   502      */
       
   503         
       
   504     /**
       
   505      * Timestamp
       
   506      */
       
   507     TTime iNmsTimestamp; 
       
   508     
       
   509     /**
       
   510      * Type of Event ( i.e., "find" or "launch" )
       
   511      */
       
   512     TInt iNmsType;
       
   513     
       
   514     /**
       
   515      * Nms Event Current netwrok type
       
   516      */
       
   517     TInt iNmsCurrentNetwork;
       
   518     
       
   519     /**
       
   520      * Nms Event Home Operator
       
   521      */
       
   522     TInt iNmsHomeOperator;   
       
   523     };
       
   524 
       
   525 #endif //C_IRSESSIONLOGGER_H